Home > Database > Mysql Tutorial > body text

mysql replace()批量替换指定字符实现语句

WBOY
Release: 2016-06-07 17:51:20
Original
1019 people have browsed it

以前我有讲过关于在mysql中利用update和replace函数来实现批量替换我们指定 的内容,其实方法很简单的有需要的朋友看看

批量替换的具体语法是:

 代码如下 复制代码
UPDATE 表名 SET
指定字段 = replace(指定字段, ’要替换的字符串’, ’想要的字符串’)
WHERE 条件;

如果你想把 article 表中 ID 小于5000的记录,content 字段中“解决”替换成“解放”,那么语法就是:

 代码如下 复制代码

UPDATE article SET
content = replace(content, ’解决’, ’解放’)
WHERE ID

后面的where可以自己定义哦,好了喜欢就看看吧。

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!