From: Jeff Hoffmann <jeff@propertykey.com>
To: Nikolay Mijaylov <nmmm@nmmm.nu>
Cc: pgsql-sql@postgresql.org
Subject: Re: fetching rows
Date: Mon, 30 Oct 2000 13:02:20 -0600
Message-ID: <39FDC5BC.43C5AE76@propertykey.com> (raw)
References: <NDBBJGGFCLFEEGHHKCABCEGCDIAA.nmmm@nmmm.nu>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jeff@propertykey.com, nmmm@nmmm.nu
Subject: Re: fetching rows
In-Reply-To: <39FDC5BC.43C5AE76@propertykey.com>
References: <NDBBJGGFCLFEEGHHKCABCEGCDIAA.nmmm@nmmm.nu> <39FDC5BC.43C5AE76@propertykey.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox