如下图数据
需要将数据处理成
在这里我们需要用到mysql函数SUBSTRING_INDEX和mysql表mysql.help_topic
substring_index(str,delim,count)
通过如下语句,则可实现一行转多行,最终实现上图的效果
以前有高人写过类似的:select id,group_concat(re_id order by re_id separator ",") as re_id
from tablename
group by id
方法2:
select group_concat(list_name) from aa_list
你可以这样
select id,type,name,c1 as c_n unionselect id,type,name,c2 as c_n union
select id,type,name,c3 as c_n union
select id,type,name,c4 as c_n union
select id,type,name,c5 as c_n order by id;
看看行不
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)