Re: [SQL] count() question
От | Peter Eisentraut |
---|---|
Тема | Re: [SQL] count() question |
Дата | |
Msg-id | Pine.LNX.4.21.9912181655230.356-100000@localhost.localdomain обсуждение исходный текст |
Ответ на | count() question ("Mitch Vincent" <mitch@venux.net>) |
Список | pgsql-sql |
On 1999-12-17, Mitch Vincent mentioned: > So my question is, is there anyway you can get the total number of results > (using count() or something) and still use the limit directive in the same > query? I tried looking at the number of result rows too but 10 (the limit) > is all I come up with. > > I would really like to avoid doing 2 full queries here, if anyone has any > suggestions please let me know. Why do you want to avoid that? If you need two different results then you probably have to use two different queries. I assume you need the count to display something like "x matches found" and use LIMIT/OFFSET to step through them page by page. In that case there is really no way but to query twice. If your query is really complicated and slow you might want to put the complete query results in a temporary table, and select the count and the to-be-displayed data from there. -- Peter Eisentraut Sernanders väg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden
В списке pgsql-sql по дате отправления: