如题,目前项目升级中用到将数据表中的多个旧字段合并到一个字段中显示,用到 CONCAT函数,如下所示:
update tab1 set goods_stcids = CONCAT(",",gc_id_1, ",",gc_id_2,",", gc_id_3)
where store_id = 1 and goods_stcids = ''
and gc_id_1 > 0 and gc_id_2 > 0 and gc_id_3 > 0;
如上,将商城id为1 的所有为空的goods_stcids 字段填充为 gc_id_1、gc_id_2、gc_id_3 三个非空字段以 ,分割 的新值。