mysql update query with inner join

后端 未结 2 1695
逝去的感伤
逝去的感伤 2021-01-23 01:48

I have two tables customer and order. I want to update different values in both tables with one query. For example customer table has a city column and value is germany and orde

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-23 02:35

    It is very simple to update using a join query in SQL.You can even join two or more tables. Here is an example :

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

提交回复
热议问题