Re: UPDATE with Oracle ??? with join ???

From: Turkbear <john.g_at_dot.spamfree.com>
Date: Wed, 19 Nov 2003 13:12:49 -0600
Message-ID: <jrfnrv8a84h471i5v51qd08pis1cftkq1d_at_4ax.com>


"rogers" <toto_at_club-toto.fr> wrote:

>I'm a young SQL developper with Oracle.
>
>With SQl server or Ingres you can excute this kind of query :
>
>update table1 from table2
>set table1.col2 = table2.col2 where
>table1.col1 = table2.col1
>
>or
>
>update table1
>set table1.col2 = table2.col2
>from table2
> where table1.col1 = table2.col1
>
>
>can we do this kind of update with a join using Oracle (9i) ??
>Please help me by giving me an exemple that works !!!
>
>Thanks
>

update table1 t1 set col2 = (select col2 from table2 where table2.col2 = table1.col2);

should do it, it you want every row in table1 to be updated...If not, then you need to add a qualifying statement like:

update table1 set col2 = (select col2 from table2 where table2.col2 = table1.col2) where table1.col2 is NULL; Received on Wed Nov 19 2003 - 20:12:49 CET

Original text of this message