[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-sql
Subject: Re: [SQL] UPDATE & LIMIT together?
From: Bruce Momjian <pgman () candle ! pha ! pa ! us>
Date: 2002-08-28 17:01:36
[Download RAW message or body]
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
---------------------------(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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic