How to do 3 table JOIN in UPDATE query?

后端 未结 6 2038
走了就别回头了
走了就别回头了 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:57

    the answer is yes you can

    try it like that

    UPDATE TABLE_A a 
        JOIN TABLE_B b ON a.join_col = b.join_col AND a.column_a = b.column_b 
        JOIN TABLE_C c ON [condition]
    SET a.column_c = a.column_c + 1
    

    EDIT:

    For general Update join :

       UPDATE TABLEA a 
       JOIN TABLEB b ON a.join_colA = b.join_colB  
       SET a.columnToUpdate = [something]
    

提交回复
热议问题