Skip to content

Instantly share code, notes, and snippets.

@rrguntaka
Created December 7, 2011 20:59

Revisions

  1. rrguntaka created this gist Dec 7, 2011.
    6 changes: 6 additions & 0 deletions update_with_select.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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)