At 20:03 20/02/02, Steve wrote:
>If I am running a query I know could return 1000's of rows;
>is there a PG way to say to just return the first, say, 50 rows?
SELECT * FROM table LIMIT 50;
If you wanted rows 51-100 you'd use
SELECT * FROM table LIMIT 50 OFFSET 50;
and in general LIMIT n OFFSET m will return rows from m+1 to m+n inclusive.
Bear in mind though that for 'the first 50' to be meaningful you'll likely
have to be using an ORDER BY clause.
Digital Mind Games -- log on to take over
In response to
pgsql-novice by date
|Next:||From: Stephen Ingram||Date: 2002-02-20 21:11:10|
|Subject: Re: Question about restricting the number of rows returned from a query.|
|Previous:||From: Philip Hallstrom||Date: 2002-02-20 20:50:02|
|Subject: Re: Question about restricting the number of rows returned from a|