mysql update语句添加表关联查询

UPDATE tab_game_version  as a INNER JOIN tab_game_version as b ON a.id=b.id
SET a.advert_data=0 where a.advert_data is NULL

UPDATE table1 AS a LEFT JOIN (SELECT CONCAT(p.f_area_name,s.f_area_name,t.f_area_name) addressPrefix,t.f_area_id FROM table2 t LEFT JOIN table3 s ON t.f_city_code=s.f_area_id LEFT JOIN table4 p ON s.f_province_code=p.f_area_id) AS b ON a.f_address_area=b.f_area_id SET a.f_address_prefix=b.addressPrefix;


UPDATE table1 AS a LEFT JOIN (SELECT CONCAT(p.f_area_name,s.f_area_name,t.f_area_name) addressPrefix,t.f_area_id FROM table2 t LEFT JOIN table3 s ON t.f_city_code=s.f_area_id LEFT JOIN table4 p ON s.f_province_code=p.f_area_id) AS b ON a.f_store_area=b.f_area_id SET a.f_address_prefix=b.addressPrefix;

 

update a inner join (select b from c) d on a.e=d.e set a.f=2 where a.g=3

posted @ 2018-01-03 15:57  ppjj  阅读(5467)  评论(0编辑  收藏  举报