行转列的实现方式:使用mysql.help_topic
--行转列 SELECT b.help_topic_id, substring_index( a.levels, ',', b.help_topic_id +1 ), substring_index( substring_index( a.levels, ',', b.help_topic_id+1 ), ',',- 1 ) AS level FROM ( select '1,2,3,4' as levels from mysql.db limit 1 ) a JOIN mysql.help_topic b ON b.help_topic_id < ( length( a.levels ) - length( REPLACE ( a.levels, ',', '' ) ) +1 )
演示效果
(1)转换前
select '1,2,3,4' as levels from mysql.db limit 1 ;
(2)转换后
标签:help,方式,mysql,topic,转列,levels,MYSQL,id From: https://www.cnblogs.com/yeyuzhuanjia/p/17261915.html