Re: fetching rows

From: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
To: Jeff Hoffmann <jeff(at)propertykey(dot)com>, Nikolay Mijaylov <nmmm(at)nmmm(dot)nu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: fetching rows
Date: 2000-11-17 03:09:14
Message-ID: 00111622091407.30061@comptechnews
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)comptechnews(dot)com ---------
- CompTechNews Message Board http://www.comptechnews.com/ -
- CompTechServ Tech Services http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Astrid Hexsel 2000-11-17 03:33:17 delete more than one row
Previous Message Gary Farmer 2000-11-17 00:02:32 RE: SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3)