Re: count() and multiple tables
От | Josh Berkus |
---|---|
Тема | Re: count() and multiple tables |
Дата | |
Msg-id | web-26888@davinci.ethosmedia.com обсуждение исходный текст |
Ответ на | count() and multiple tables (Joseph Shraibman <jks@selectacast.net>) |
Список | pgsql-sql |
Joseph, SImple as pie (e.g., easy on your 100th one): > select count(*) from d where status = 2 and d.id = u.dkey and > u.status = > 2 and not u.b and u.akey = a.key and a.status = 3; Count(*) will always count the number of records in the largest table in your join. If you want the number of records in a specific table, then you have to make sure that that table is the only on in your FROM clause, and reference all other tables in WHERE: select count(*) from d where id IN (select u.dkey from u, a where u.akey = a.key AND u.status = 2 and not u.b and a.status = 3); -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete informationtechnology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco
В списке pgsql-sql по дате отправления: