Option A) A correlated subquery
UPDATE MyTable t
SET Col1 = (SELECT o.col2 FROM OtherTable o WHERE t.OtherID = o.ID)
This requires that the subquery return no more than 1 match for each row in the table being updated. If it returns no match, the column will be updated with NULL
, which may not be what you want. You could add WHERE EXISTS (SELECT o.col2 FROM OtherTable o WHERE t.OtherID = o.ID)
to cause the update to only occur where a match is found.
Option B) Updating a join view
UPDATE (SELECT t.col1, o.col2 FROM MyTable t JOIN OtherTable o ON t.otherID = o.ID)
SET col1 = col2
This is closer to what you are used to doing. It will only work if Oracle can determine a unique row in the underlying table for each row in the join -- which I think basically means that ID
must be a unique key of otherTable
.