How to do 3 table JOIN in UPDATE query?

后端 未结 6 2042
走了就别回头了
走了就别回头了 2020-11-21 07:00

I asked a question and got this reply which helped.

   UPDATE TABLE_A a JOIN TABLE_B b 
   ON a.join_col = b.join_col AND a.column_a = b.column_b 
   SET a.c         


        
6条回答
  •  难免孤独
    2020-11-21 07:54

    Yes, you can do a 3 table join for an update statement. Here is an example :

        UPDATE customer_table c 
    
          JOIN  
              employee_table e
              ON c.city_id = e.city_id  
          JOIN 
              anyother_ table a
              ON a.someID = e.someID
    
        SET c.active = "Yes"
    
        WHERE c.city = "New york";
    

提交回复
热议问题