From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | tp(at)emaze(dot)net |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: UPDATE & LIMIT together? |
Date: | 2002-08-28 17:01:36 |
Message-ID: | 200208281701.g7SH1aI20777@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Haddon | 2002-08-28 17:44:57 | Case Statement |
Previous Message | friedrich nietzsche | 2002-08-28 16:51:36 | nextval... |