Re: select question

From: g <brian(at)wuwei(dot)govshops(dot)com>
To: database(at)gurubase(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select question
Date: 2000-07-31 14:42:34
Message-ID: Pine.LNX.4.21.0007310940380.19532-100000@wuwei.govshops.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Use the limit clause.

SELECT message_text FROM messages ORDER BY creation_date LIMIT $limit,
$offset.

LIMIT 10, 0 gets you the first batch.
LIMIT 10, 10 gets you the second batch.
LIMIT 10, 20 gets you the third, etc.

-----------------------------------------
Water overcomes the stone;
Without substance it requires no opening;
This is the benefit of taking no action.
Lao-Tse

Brian Knox
Senior Systems Engineer
brian(at)govshops(dot)com

On Sun, 30 Jul 2000 database(at)gurubase(dot)com wrote:

> Dear all,
>
> Is there a way I can select the top 50 rows from table, 51 - 100 rows from
> table etc.... (with order clause)? It is because I am writing a message board
> and I would like to create the prev/next button on different page.
>
> Many thanks.
>
> Best regards,
> Boris
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-07-31 14:55:21 Re: select question
Previous Message Tom Lane 2000-07-31 14:38:47 Re: Rules & sequences