9 Replies Latest reply: Jul 18, 2014 11:53 AM by Frank Kulash RSS

    Update multiple columns from multiple tables in a single UPDATE Query

    user5534771

      Good Morning,

       

      I am trying to figure out if I am heading in the the right direction.

      I want to update multiple columns from multiple tables in a single UPDATE query. Also, I would like to update multiple columns in one table from multiple tables.

       

      Scenario 1

      UPDATE Table2, Table 3
      SET T2.Column1 = T1.Column1 
      ,T2.Column2 = T1.Column2
      ,T3.Column2 = T1.Column2
      FROM Table1 T1, Table2 T2, Table3 T3
      WHERE T1.id = T2.id
      and T1.id = T3.id
      
      

       

      Scenario 2

       

      UPDATE Table3
      SET T3.Column1 = T1.Column1 
      T3.Column2 = T1.Column2
      ,T3.Column3 = T2.Column3
      ,T3.Column4 = T2.Column4
      FROM Table1 T1, Table2 T2, Table3 T3
      WHERE T3.id = T1.id
      and T3.id = T2.id