三级:mysql的replace函数替换字符串
![](http://www.onekao.net/templets/default/images/content_ad.gif)
replace 函数即可批量改变某字段中的某一段字符串。
查 mysql 里的 replace 函数
update `xxx` set `a` = replace(`a` , ’要替换的’ , ’替换为的’) where xxx
===PHPCHINA.COM===============================================================
update `xxx` set `a` = replace(`a` , ’要替换的’ , ’替换为的’) where xxx
update `music` set `file` = replace(`file` , ’’ , ’ddd’) where id<10
UPDATE music SET file=REPLACE(file, ’’, ’def’) where id < 10 ;
===mysql.com===============================================================
用mysql的replace函数替换字符串
比如你要将 表 tb1里面的 f1字段的abc替换为def
UPDATE tb1 SET f1=REPLACE(f1, ’abc’, ’def’);
REPLACE(str,from_str,to_str)
在字符串 str 中所有出现的字符串 from_str 均被 to_str替换,然后返回这个字符串:
mysql> SELECT REPLACE(’www.mysql.com’, ’w’, ’Ww’);
-> ’WwWwWw.mysql.com’
这个函数是多字节安全的。
查 mysql 里的 replace 函数
update `xxx` set `a` = replace(`a` , ’要替换的’ , ’替换为的’) where xxx
===PHPCHINA.COM===============================================================
update `xxx` set `a` = replace(`a` , ’要替换的’ , ’替换为的’) where xxx
update `music` set `file` = replace(`file` , ’’ , ’ddd’) where id<10
UPDATE music SET file=REPLACE(file, ’’, ’def’) where id < 10 ;
===mysql.com===============================================================
用mysql的replace函数替换字符串
比如你要将 表 tb1里面的 f1字段的abc替换为def
UPDATE tb1 SET f1=REPLACE(f1, ’abc’, ’def’);
REPLACE(str,from_str,to_str)
在字符串 str 中所有出现的字符串 from_str 均被 to_str替换,然后返回这个字符串:
mysql> SELECT REPLACE(’www.mysql.com’, ’w’, ’Ww’);
-> ’WwWwWw.mysql.com’
这个函数是多字节安全的。