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 -> Update a Table from a Second Table

Update a Table from a Second Table

From: Greg <ghvance_at_yahoo.com>
Date: 27 Jun 2003 13:53:06 -0700
Message-ID: <102c7417.0306271253.216a2b80@posting.google.com>


This is an easy way to update a table from a second table in Sql Server.

update table1
set table1.col2 = table2.col2
from table1, table2
where table1.keycol = table2.keycol

I know you can do something like this in Oracle:

update table1 a
set table1.col2 = (select col2 from table2 where table2.keycol = a.keycol)

but that example will update every row in table1, not just the ones that match the rows in table2.

The sql server version not only gets the values it needs from the second table, it also limits the rows updated to those the matching rows in table2.

Is there an easy way to do this in Oracle?

thanks much Received on Fri Jun 27 2003 - 15:53:06 CDT

Original text of this message

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