faqts : Computers : Programming : Languages : PHP : Database Backed Sites : Postgres

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

31 of 35 people (89%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I limit the number of records returned by PostgreSQL ?

Dec 9th, 2002 08:48
Jonathan Ellis, Nathan Wallace, Eric van der Vlist, Gareth Cantrell


With any reasonably current version of PG, you can use the
SELECT...LIMIT statement.
    eg: SELECT * FROM class LIMIT 200;
To get the next 200 entries use:
    SELECT * FROM class LIMIT 200 OFFSET 201;
You can also use the "set query_limit" statement.  It will be valid for the
connection until you reset it.
    eg: pg_Exec ($conn, "set QUERY_LIMIT='200'");