Re: Can you specify multiple tables in update's where clause?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 16 Jul 2001 13:01:57 -0700
Message-ID: <9ivh7l0pp3_at_drn.newsguy.com>


In article <32G47.10371$rK3.840232_at_news1.onlynews.com>, ssoni says...
>
>Actually, he specifically wanted a join UPDATE, not a subquery. This
>doesn't require any hardcoding of values in the SQL... Not sure this is
>valid in ORCL....it is in SYBASE
>
>For example: update accts set a2.account_name = a1.account_name from
>accounts a1, accts a2 where a1.acct_id = a2.acct_id

and the standard syntax for this would be:

update
  ( select a2.account_name a2_account_name,

           a1.account_name a1_account_name
      from accounts a1, accts a2
     where a1.acct_id = a2.acct_id )

 set a2_account_name = a1_account_name
/

and that Oracle does support.

>===============================
>
>Originally posted by Hans Noordhof Try this
>
>update table_a set table_a.my_col = 'Like This' where table_a.col_a in
>(select table_x.col_b from table_x , table_y where table_x.col_x=
>table_y.col_d ) And buy an SQL-book.
>
>
>
>
>--
>Posted via dBforums, http://dbforums.com

--
Thomas Kyte (tkyte_at_us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Mon Jul 16 2001 - 22:01:57 CEST

Original text of this message