Skip to content

Instantly share code, notes, and snippets.

@rrguntaka
Created December 7, 2011 20:59
Show Gist options
  • Save rrguntaka/1444622 to your computer and use it in GitHub Desktop.
Save rrguntaka/1444622 to your computer and use it in GitHub Desktop.
Update with Select (Oracle). This query is to update a set of columns with the data from a subselect by matching id
UPDATE table_to_be_updated t1
SET (t1.col1, t1.col2) =
(SELECT (t2.col1, t2.col2) subquery_or_table t2
WHERE(t2.id1, t2.id2) in (t1.id1,t1.id2))
WHERE (t1.id1, t1.id2) IN
(select t2.id1, t2.id2 from subquery_or_table t2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment