mysql 替換字符串的實現方法:
mysql中replace函數直接替換mysql數據庫中某字段中的特定字符串,不再需要自己寫函數去替換,用起來非常的方便,mysql 替換函數replace()
Update `table_name` SET `field_name` = replace (`field_name`,’from_str’,'to_str’) Where `field_name` LIKE ‘%from_str%’
實例:把'病假' 替換為 '--':UPDATE users SET username=REPLACE(username,'病假','--') WHERE username LIKE '%病假%';
說明:
table_name —— 表的名字
field_name —— 字段名
from_str —— 需要替換的字符串
to_str —— 替換成的字符串