啥?

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
-- 语法: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 = '')

 

posted on 2022-03-31 10:34  啥?  阅读(111)  评论(0编辑  收藏  举报