MySQL修改某一列的前几个字符

-- 用子查询的值,替换掉前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 ) )

参考 https://www.zhihu.com/question/51964872

上一篇:vue中子父组件传值使用$emit,$on,$off


下一篇:第四章 索引及执行计划