Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> join in an update statement
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
Received on Tue Feb 26 2002 - 19:37:06 CST