Home  >  Article  >  Database  >  mysql查询字符串替换语句小结(数据库字符串替换)

mysql查询字符串替换语句小结(数据库字符串替换)

WBOY
WBOYOriginal
2016-06-07 18:07:391103browse

有时候我们需要对mysql的字符串进行替换,我们就可以通过sql语句直接实现了,不过对于大数据量的字段不建议使用此方法

将ubk_vhost_list表中的字段userid中的字符10005替换成10010

UPDATE `table_name` SET `field_name` = replace (`field_name`,'from_str','to_str') WHERE `field_name` LIKE '%from_str%'

说明:
table_name —— 表的名字
field_name —— 字段名
from_str —— 需要替换的字符串
to_str —— 替换成的字符串

今天运行了一个查询
UPDATE ubk_vhost_list SET userid = replace (userid,'10005','10010')

比较详细的mysql字符串替换语句可以参考下面的文章
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