您的位置:首页 > 数据库 > MySQL

[mysql] mysql如何实现更新一条记录中某个字段值的一部分呢?

2015-10-12 20:37 726 查看
场景:在平常我们使用word文档等等office办公软件时,我们常会使用搜索->替换的功能。

mysql: 在mysql 中有时候,我们也需要这样子的实现;

实现 SQL 语句: update t_liucheng set f_buzhouneirong = replace(f_buzhouneirong, '0755-86934380', '0755-36882648') where instr(f_buzhouneirong , '0755-86934380') > 0;

//使用方法:


Change
table_name
and
field
to match your table name and field in question:

update table_name set field = replace(field, 'foo', 'bar') where instr(field, 'foo') > 0;


//Stackoverflow原文链接: http://stackoverflow.com/questions/125230/mysql-search-and-replace-some-text-in-a-field
// Mysql String Functions Manual 链接: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: