添加前、後綴 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");
為了讓各位更加清楚我們看幾個例子
添加前綴
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為產品字段名