# 模糊批量替换关键字
update blog_chat set messages=REPLACE(messages,’admin’,’管理员’) where messages like ‘%admin...翻成白话:REPLACE(String,from_str,to_str) 即:将String中所有出现的from_str替换为to_str。...二、查询替换
2.1 将address字段里的 “区” 替换为 “呕” 显示,如下
select *,replace(address,’区’,’呕’) AS rep
from test_tb
?...总结:联想到前面有讲过 使用IF(expr1,expr2,expr3) 及 CASE…WHEN…THEN…END 可以实现查询结果的别名显示,
但区别是:这两者是将查询结果值做整体的别名显示,而replace...三、更新替换
3.1 将address字段里的 “东” 替换为 “西” ,如下
update test_tb set address=replace(address,’东’,’西’) where id