Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B034B476284 for ; Tue, 3 Sep 2002 04:36:57 -0400 (EDT) Received: from wired.emaze.net (proxy.ingsoc.org [213.178.220.5]) by postgresql.org (Postfix) with ESMTP id 0458F475EF7 for ; Tue, 3 Sep 2002 04:36:45 -0400 (EDT) Received: (from tp@localhost) by wired.emaze.net (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id g838bRp08312; Tue, 3 Sep 2002 08:37:27 GMT Date: Tue, 3 Sep 2002 08:37:27 +0000 From: tp To: Bruce Momjian Cc: pgsql-sql@postgresql.org Subject: Re: UPDATE & LIMIT together? Message-ID: <20020903083727.GH5674@emaze.net> Reply-To: tp@emaze.net References: <20020828160929.GL20155@emaze.net> <200208281701.g7SH1aI20777@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200208281701.g7SH1aI20777@candle.pha.pa.us> User-Agent: Mutt/1.3.25i X-Sender: tp@emaze.net X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/4 X-Sequence-Number: 9281 Hmm,, thanks so far, it helped. The query is horrible slow on full tables (>100.000 rows). Is there any other solution? I just want to have the 'next 10 entries' WHERE state=10 and update state=20. (so that on the next request i or another process only gets the new entires in queue). My query now looks like: UPDATE queue SET state=20 WHERE (id) IN (SELECT id FROM queue LIMIT 10) -tp Bruce Momjian(pgman@candle.pha.pa.us)@Wed, Aug 28, 2002 at 01:01:36PM -0400: > > You have to use a subquery returning the tables primary key to the > UPDATE: > > UPDATE tab SET x=1 > WHERE (primkey, col) IN ( > SELECT primkey,col FROM tab > ORDER BY col > LIMIT 10) > > --------------------------------------------------------------------------- > > tp wrote: > -- Start of PGP signed section. > > Hi > > > > I want to SELECT at max. 10 rows and SET a variable for the > > select 10 rows with the same query. > > > > Under mysql i can use: > > UPDATE table SET uniq_iq=12345 LIMIT 10 > > SELECT * FROM table WHERE uniq_id=1234;