我們介紹到了添加前、后綴,字符串替換會(huì)使用到兩個(gè)函數(shù),一個(gè)是concat另一個(gè)是replace函數(shù)了,下面我們就一起來看看吧.
添加前、后綴 concat,字符串替換 replace
添加前綴:UPDATE `table` SET field_name = concat("前綴", field_name);
添加后綴:UPDATE `table` SET field_name = concat(field_name, "后綴");
批量替換:UPDATE `table` SET field_name = REPLACE(intro, "before_replace", "after_replace");
為了讓各位更加清楚我們看幾個(gè)例子
添加前綴:update `ecs_goods` set goods_name=concat('新中式',goods_name) where cat_id =4;
添加后綴:update `ecs_goods` set goods_name=concat(goods_name,'新中式') where cat_id =4;
刪除:update `ecs_goods`set goods_name=right(goods_name,length(goods_name)-1) where cat_id =4;
其中ecs_goods為表名,cat_id為分類字段名,goods_name為產(chǎn)品字段名.
新聞熱點(diǎn)
疑難解答
圖片精選