Re: fetching rows

From: Jeff Hoffmann <jeff(at)propertykey(dot)com>
To: Nikolay Mijaylov <nmmm(at)nmmm(dot)nu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: fetching rows
Date: 2000-10-30 19:02:20
Message-ID: 39FDC5BC.43C5AE76@propertykey.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Nikolay Mijaylov wrote:
>
> Let say we have a select that returns 100 rows.
>
> I can fetch first 25 with simple sql:
>
> BEGIN WORK;
> DECLARE liahona CURSOR FOR SELECT * FROM films;
> FETCH [FORWARD] 25 IN liahona;
> CLOSE liahona;
> COMMIT WORK;
>
> but how I can fetch rows from 26 to 50? I mean withou fetching first 25. Or
> can I skip first 25?

you can't do that with a cursor, but you can use they mysql-ism called a
limit clause. for example, to fetch rows 26-50 from that query, you'd
do:

select * from films limit 25,26;

or

select * from files limit 25 offset 26;

--

Jeff Hoffmann
PropertyKey.com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Martin Christensen 2000-10-30 22:07:19 Re: fetching rows
Previous Message K Parker 2000-10-30 18:58:52 Re: fetching rows