mysql查询替换语句
#模糊查询语句
SELECT * FROM `table_name` WHERE `field_name` LIKE '%from_str%'
#替换语句
UPDATE `table_name` SET `field_name` = replace (`field_name`,'from_str','to_str') WHERE `field_name` LIKE '%from_str%'
例如:
#select * from typecho_contents where `text` like '%(http://blog.diynet.top/usr%'
#update typecho_contents set `text` = replace (`text`,'(http://blog.diynet.top/usr','(/usr') where `text` LIKE '%(http://blog.diynet.top/usr%'
说明:
- table_name —— 表的名字
- field_name —— 字段名
- from_str —— 需要替换的字符串
- to_str —— 替换成的字符串
今天运行了一个查询
UPDATE ubk_vhost_list SET userid = replace (userid,'10005','10010')
将ubk_vhost_list表中的字段userid中的字符10005替换成10010
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。