-- 用子查询的值,替换掉前4个字符,验证 SELECT concat( ( SELECT city_code FROM business_department WHERE id = p.city ), RIGHT ( new_code, CHAR_LENGTH( new_code ) - 4 ) ) FROM business_project p ORDER BY new_code DESC; -- 更新 UPDATE business_project p SET p.new_code = concat( ( SELECT city_code FROM business_department WHERE id = p.city ), RIGHT ( new_code, CHAR_LENGTH( new_code ) - 4 ) )