Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> join in an update statement

join in an update statement

From: Jeff Goodman <JGoodman10_at_nyc.rr.com>
Date: Wed, 27 Feb 2002 01:37:06 GMT
Message-ID: <6LWe8.35514$Ci6.6226336@typhoon.nyc.rr.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US