Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 18:07:39
Original
1125 people have browsed it

有时候我们需要对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字符串替换语句可以参考下面的文章
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template