Re: fetching rows - Mailing list pgsql-sql

From Robert B. Easter
Subject Re: fetching rows
Date
Msg-id 00111622091407.30061@comptechnews
Whole thread Raw
In response to Re: fetching rows  (Jeff Hoffmann <jeff@propertykey.com>)
List pgsql-sql
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/ ------------


pgsql-sql by date:

Previous
From: "Gary Farmer"
Date:
Subject: RE: SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3)
Next
From: "Astrid Hexsel"
Date:
Subject: delete more than one row