X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8643A475AE5 for ; Wed, 12 Feb 2003 14:00:26 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 2571C475AFA for ; Wed, 12 Feb 2003 14:00:26 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 0A5C943A756; Wed, 12 Feb 2003 14:00:26 -0500 (EST) From: Dmitry Tkach X-Newsgroups: comp.databases.postgresql.sql Subject: Re: How do you select from a table until a condition is met? Date: Wed, 12 Feb 2003 15:39:03 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 52 Message-ID: <3E4AB0E7.3010101@openratings.com> References: <200302121910.38232.nallen@freenet.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org To: Nicholas Allen User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en In-Reply-To: <200302121910.38232.nallen@freenet.co.uk> To: pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/245 X-Sequence-Number: 11643 select * from table order by x limit 10; -- get first 10 select * from table order by x offset 10 limit 10; -- get 10 - 20 select * from table order by x offset 40 limit 10; -- get 40-50 OR begin; declare mycursor cursor for select * from table order by x; fetch 10 from mycursor; -- get first 10 fetch 10 from mycursor; -- get 10-20 move 20 in mycursor; fetch 10 from mycursor; -- get 40-50 Is that what you are talking about? Dima Nicholas Allen wrote: > Hi, > > I am hoping that someone can help me with a problem I have. I would like to= > be=20 > able to perform a SELECT query to select values from a table upto a certain= > =20 > row. The select may be ordered on a number of items. Is it possible to do= > =20 > this and how should I do it? > > The reason I need this is because I have created a virtual table browser cl= > ass=20 > that performs SQL queries to get the sections of the table the user is=20 > interested in. This way I don't load the whole table onto the client side. = > If=20 > the user changes the sort ordering I want to determine the row index that w= > as=20 > previously selected and scroll to that location. > > Any help would be very much appreciated. > > Thanks in advance, > > Nicholas Allen > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly