1. 程式人生 > >Mysql replace替換欄位中的指定字串

Mysql replace替換欄位中的指定字串

replace用法:replace("欄位名","原字串","替代後的字串")

用法示例:替換expand_url中https為http

原資料:

為了識別率更高加上冒號

update jianjie_task_list_tg set expand_url = replace(expand_url,'https:','http:');

執行後資料:

也可以加條件:

update jianjie_task_list_tg set expand_url = replace(expand_url,'http:','https:') where id =6;

update jianjie_task_list_tg set expand_url = replace(expand_url,'/test1.jiujijianghu.com/','/www.baidu.com/') where id =6;