Count Total on a limited query?

From: "Koen Antonissen" <Koen(at)Cee-Kay(dot)net>
To: "pgsql-sql" <pgsql-sql(at)postgresql(dot)org>
Subject: Count Total on a limited query?
Date: 2002-01-16 12:55:18
Message-ID: DD782DD61CF86144BD78DDC89D3D6124083F46@gaea.home.dutchcentral.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi group,

I've implemented a couple of search queries, to prevent too many results
transferring/getting displayed I use a LIMIT. Now I would like to
display the total numbers found on the query (discarding the limit).

Is this possible in a nice manner?
I thought up the following:
1. Implementing the limit system in PHP
Con: Too much work for something this elementary
2. Executing an extra search query which only counts
Con: An extra query which feels unnecessary
3. Using a subselect which only counts
Con: although it gives a nice result, and isn't much work, the query
will be executed for each record and therefore not an option.

I hope this can be done using PostgreSQL.

Thank you,
Koen Antonissen

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Bertheau 2002-01-16 13:28:54 reforming query for 7.0.2
Previous Message Marius Andreiana 2002-01-16 07:15:16 psql bug: copy paste statements looses tab character