Re: Question about restricting the number of rows

Поиск
Список
Период
Сортировка
Искать
От
Mo Holkar
Тема
Re: Question about restricting the number of rows
Дата
Msg-id
5.1.0.14.2.20020220205546.04d59010@pop.ntlworld.com
Ответ на
Список
Дерево обсуждения
Question about restricting the number of rows returned from a query. Stephen Ingram <ingram@samsix.com>
Re: Question about restricting the number of rows returned Tuna Chatterjee <tchatter@alert.infoplease.com>
Re: Question about restricting the number of rows returned from a Philip Hallstrom <philip@adhesivemedia.com>
Re: Question about restricting the number of rows returned from a query. Stephen Ingram <ingram@samsix.com>
Re: Question about restricting the number of rows Mo Holkar <pgsql@digitalmindgames.com>
Re: Question about restricting the number of rows Stephen Ingram <ingram@samsix.com>
At 20:03 20/02/02, Steve wrote:


>Hi,
>
>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?

Like this:

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.

best,

Mo




Mo Holkar
Digital Mind Games -- log on to take over
mo.holkar@digitalmindgames.com
http://www.digitalmindgames.com

В списке pgsql-novice по дате отправления
От: Philip Hallstrom
Дата:
От: Stephen Ingram
Дата:
FAQ