Received: from comptechnews.com (cc993546-b.srst1.fl.home.com [24.3.77.52]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eAH33Xs09686 for ; Thu, 16 Nov 2000 22:03:33 -0500 (EST) (envelope-from reaster@comptechnews.com) Received: from localhost (localhost [[UNIX: localhost]]) by comptechnews.com (8.9.3/8.9.3) id WAA15051; Thu, 16 Nov 2000 22:09:14 -0500 From: "Robert B. Easter" Date: Thu, 16 Nov 2000 22:09:14 -0500 X-Mailer: KMail [version 1.1.99] Content-Type: text/plain; charset="us-ascii" Cc: pgsql-sql@postgresql.org To: Jeff Hoffmann , Nikolay Mijaylov References: <39FDC5BC.43C5AE76@propertykey.com> In-Reply-To: <39FDC5BC.43C5AE76@propertykey.com> Subject: Re: fetching rows MIME-Version: 1.0 Message-Id: <00111622091407.30061@comptechnews> Content-Transfer-Encoding: 8bit X-Archive-Number: 200011/129 X-Sequence-Number: 160 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/ ------------