mysql将一行变成多行的方法:
把
转成
select substring_index(substring_index( a.rn,',',b.help_topic_id + 1 ),',' ,- 1) as rnfrom (select '1,2,3,4' as rn) a join mysql.help_topic b on b.help_topic_id <(length(a.rn) - length( replace(a.rn, ',', '') ) + 1)
图a转成图b
图a
图b
select substring_index(substring_index( a.rn,',',b.help_topic_id + 1 ), ',' ,- 1 ) as rnfrom (select substr(group_concat( repeat(concat(number,','),fre) separator ''),1,length(group_concat( repeat(concat(number,','),fre) separator ''))-1) as rn from numbers ) a join mysql.help_topic b on b.help_topic_id <(length(a.rn) - length( replace(a.rn, ',', '') ) + 1)
更多相关免费学习推荐:mysql教程(视频)
以上就是mysql如何将一行变成多行的详细内容。
