Home >Backend Development >PHP Tutorial > 批量替换某表里面某个字段的关键字,sql应该如何写

批量替换某表里面某个字段的关键字,sql应该如何写

WBOY
WBOYOriginal
2016-06-13 13:01:02805browse

批量替换某表里面某个字段的关键字,sql应该怎么写
批量替换表 shop 里面的 title  字段  把 "店铺"  替换  "商店"
------解决方案--------------------
update shop set title=replace(title,"店铺" , "商店" ) ;
------解决方案--------------------
UPDATE `shop` SET `title` = replace (`title`,"店铺","商店") WHERE `title` LIKE '%店铺%' 
------解决方案--------------------
最简单的方法:
1.用navicat连上你的mysql,打开shop表.
2.按一下快捷键ctrl+q组合键打开sql执行窗口,贴上语句
update shop set title=replace(title,"店铺" , "商店" );
点击运行按钮
3.下方会提示:
[SQL] update shop set title=replace(title,"店铺" , "商店" ) ;
受影响的行: 10
时间: 0.017ms
注意一下:受影响的行: 10  说明有10行替换成功了.

------解决方案--------------------
update shop set title=rrplacr(title, '店铺', '商店')

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn