X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1DA3B475EF7 for ; Wed, 12 Feb 2003 16:15:33 -0500 (EST) Received: from exchange.hq.openratings.com (unknown [141.149.165.226]) by postgresql.org (Postfix) with ESMTP id E8002476258 for ; Wed, 12 Feb 2003 16:06:28 -0500 (EST) Received: from openratings.com (cancun.hq.openratings.com [10.0.0.225]) by exchange.hq.openratings.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id DQJTWNVL; Wed, 12 Feb 2003 16:06:30 -0500 Message-ID: <3E4ACE74.109@openratings.com> Date: Wed, 12 Feb 2003 17:45:08 -0500 From: Dmitry Tkach User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Nicholas Allen Cc: Bruno Wolff III , pgsql-sql@postgresql.org Subject: Re: How do you select from a table until a condition is met? References: <200302121910.38232.nallen@freenet.co.uk> <200302122055.21790.nallen@freenet.co.uk> <20030212203749.GA30483@wolff.to> <200302122153.08970.nallen@freenet.co.uk> In-Reply-To: <200302122153.08970.nallen@freenet.co.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/263 X-Sequence-Number: 11661 Nicholas Allen wrote: >Ok I thought of that but what happens if there is no primary key in the table? > Then tough luck - as you said yourself, since everything else can be duplicated, the primary key is the only way to tell for sure which exact row you are talking about. >I can probably add primary keys to the table but I didn't design the tables >and so I have little (but luckily some) say over what columns appear in them. >What has actually happened is that we have a view on a table and the view >doesn't return the primary key. I'll try and ask the database administrator >to add the primary keys. > >Thanks for the help though I guess it is the only way to do it. I was just >hoping there would be a way to do it without a promary key to prevent changes >to our database views. > I think you are better off redesigning your interface - even if you do modify the view, and use those suggestions I mentioned earlier, it will be slow like hell, unless your table only contains a few hundred rows, in which case it doesn't matter if you send the whole table to the client every time, Dima > >On Wednesday 12 Feb 2003 9:37 pm, Bruno Wolff III wrote: > > >>On Wed, Feb 12, 2003 at 20:55:21 +0100, >> >> Nicholas Allen wrote: >> >> >>>I thought of this but the problem is that there may be multiple rows with >>>the same value for the column I am sorting on. Eg if sorting on a surname >>>then there may be 100s of people with the same surname so generating a >>>where clause that selects up to the exact person previously selected is >>>very difficult. >>> >>> >>Then you should sort on surname AND whatever you are using as the primary >>key. >> >>---------------------------(end of broadcast)--------------------------- >>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.or >> >g > >