
有没有人碰到过这种奇葩的需求,将多列合并,且重复的字符串要去掉的,求高手指点
解决方案
40
select id,group_concat(name) from ( select id,name from table1 union select id,zy_name from table1 union select id,maj_name from table1 union select id,SUBSTRING_INDEX(maj_zy_name,",",1) from table1 union select id,SUBSTRING_INDEX(maj_zy_name,",",-1) from table1 ) t group by id