Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: join in an update statement
In article <6LWe8.35514$Ci6.6226336_at_typhoon.nyc.rr.com>, "Jeff says...
>
>Can you do a join in an update statement. I only want to update one table,
>but I want to set values from table 1 to equal values from table 2. For
>example:
>
>update table1, table2
>set table1.quantity = table2.quantity
>where table1.key = table2.key
>
>The only way I can think to do it is to say:
>
>update table1
>set table1.quantity = (select table2.quantity where table1.key = table2.key)
>
>But if I have more columns I want to update, I would have to have a seperate
>subselect for each column, which could become pretty costly. I would also
>like to test it with a select clause to see what would be updated but with
>the second update, I cant think of a corresponding select.
>
>Thanks.
>Jeff
>
>
>
you can update a join -- see
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:288016031632
for the syntax/example.
-- Thomas Kyte (tkyte@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 CorpReceived on Wed Feb 27 2002 - 08:47:25 CST
![]() |
![]() |