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

场景:在平常我们使用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

原文地址:https://www.cnblogs.com/shuman/p/4872765.html