From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | "Edwin S(dot) Ramirez" <ramirez(at)idconcepts(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Update Syntax |
Date: | 2004-02-02 17:49:04 |
Message-ID: | 20040202174904.GB4402@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Jan 30, 2004 at 07:41:18 -0800,
"Edwin S. Ramirez" <ramirez(at)idconcepts(dot)org> wrote:
> Hello,
>
> I need Postgres support for the following update syntax :
>
> update table1 set (col1, col2, col3) = (select f1, f2, f3 from table2
> where id=5) where rownum=3;
>
> update table1 set (col1, col2, col3) = (select f1, f2, f3 from table2
> where id=table1.parentid) where rownum=3;
>
> These type of update statements are the only ones supported by Oracle
> to update one table from another.
As a work around you could do:
update table1 set
col1 = (select f1 from table2 where id=table1.parentid),
col2 = (select f2 from table2 where id=table1.parentid),
col3 = (select f3 from table2 where id=table1.parentid)
where rownum=3;
I don't think this will run as efficiently and it makes the query look
more complex, but it should work for both Oracle and Postgres.
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2004-02-02 19:00:38 | Re: pg_stat_activity |
Previous Message | Tom Lane | 2004-02-02 17:32:05 | Re: pg_restore bug in 7.4.1 ? |