[mysql增加字段]MySQL字段前缀、后缀、替换操作的例子

更新时间:2019-09-06    来源:mysql教程    手机版     字体:

【www.bbyears.com--mysql教程】

添加前、后缀 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为产品字段名

本文来源:http://www.bbyears.com/shujuku/66484.html

热门标签

更多>>

本类排行