情况一:数据某一列中有多个字符用英文逗号隔开,需要对其中一个字符进行替换。
示例,如下表,需要将ID为2的品牌和ID为1的品牌大小写保持一致
![](https://img-blog.csdnimg.cn/img_convert/61495c3cbe890246761a9f6e87a3440a.png)
结果表
![](https://img-blog.csdnimg.cn/img_convert/0d2030397384f5ddab65bd010eab06dd.png)
情况一:如果只有1个单词
update 表名 set A = replace(A,'huawei','Huawei') ;
update 表名 set A = replace(A,'dji','Dji') ;
情况二:如果有多个重复单词,如“xiao mi”和“mi”,需要加上where条件。
1 加上where 条件
update 表名 set A = replace(A,'xiao mi','Xiao mi') ;
update 表名 set A = replace(A,'mi','Xiao mi')
where alliance_guest_platform not like '%Xiao mi%';
结果表
![](https://img-blog.csdnimg.cn/img_convert/0d2030397384f5ddab65bd010eab06dd.png)
2 不加where条件
update 表名 set A = replace(A,'xiao mi','Xiao mi') ;
update 表名 set A = replace(A,'mi','Xiao mi') ;
结果表
![](https://img-blog.csdnimg.cn/img_convert/c14af6590d2b2be5743063955b5ec524.png)