Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DB018476452 for ; Wed, 28 Aug 2002 13:01:47 -0400 (EDT) Received: from candle.pha.pa.us (216-55-132-35.dsl.san-diego.abac.net [216.55.132.35]) by postgresql.org (Postfix) with ESMTP id C7A50476440 for ; Wed, 28 Aug 2002 13:01:46 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g7SH1aI20777; Wed, 28 Aug 2002 13:01:36 -0400 (EDT) From: Bruce Momjian Message-Id: <200208281701.g7SH1aI20777@candle.pha.pa.us> Subject: Re: UPDATE & LIMIT together? In-Reply-To: <20020828160929.GL20155@emaze.net> To: tp@emaze.net Date: Wed, 28 Aug 2002 13:01:36 -0400 (EDT) Cc: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/401 X-Sequence-Number: 9247 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; > > This is not supported by postgres. > > Is there some easy solution that does not require locking? > > > -tp -- End of PGP section, PGP failed! -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073