-- 语法:update table_1 t1,table_2 t2 set t1.column = t2.column where t1.id = t2.pid; UPDATE house_test.shareInfo AS t1, ( SELECT u.*, g.city_code FROM `api`.`user` AS u LEFT JOIN `api`.`group` AS g ON g.group_id = u.group_id ) AS t2 SET t1.cityCode = t2.city_code WHERE t1.userId = t2.user_id AND ( t1.cityCode IS NULL OR t1.cityCode = '')