pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert B. Easter <reaster@comptechnews.com>
To: Jeff Hoffmann <jeff@propertykey.com>
To: Nikolay Mijaylov <nmmm@nmmm.nu>
Cc: pgsql-sql@postgresql.org
Subject: Re: fetching rows
Date: Thu, 16 Nov 2000 22:09:14 -0500
Message-ID: <00111622091407.30061@comptechnews> (raw)
In-Reply-To: <39FDC5BC.43C5AE76@propertykey.com>
References: <NDBBJGGFCLFEEGHHKCABCEGCDIAA.nmmm@nmmm.nu>
	<39FDC5BC.43C5AE76@propertykey.com>

On Monday 30 October 2000 14:02, Jeff Hoffmann wrote:
> 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?
>

I've done some web pages that have paging.  It did it with DECLARE to make a 
cursor then I used PostgreSQL's non-standard MOVE SQL command to start 
FETCHing from some offset depending on the page number.


> 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;

-- 
-------- Robert B. Easter  reaster@comptechnews.com ---------
- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------



view thread (6+ messages)

Message-ID: <00111622091407.30061@comptechnews>
Permalink:  ../00111622091407.30061@comptechnews/
Also on:    postgresql.org/message-id/00111622091407.30061@comptechnews

 · 

reply

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: reaster@comptechnews.com, jeff@propertykey.com, nmmm@nmmm.nu
  Subject: Re: fetching rows
  In-Reply-To: <00111622091407.30061@comptechnews>
  References: <NDBBJGGFCLFEEGHHKCABCEGCDIAA.nmmm@nmmm.nu> <39FDC5BC.43C5AE76@propertykey.com> <00111622091407.30061@comptechnews>

* 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