mysql 行转列

SELECT a.*,GROUP_CONCAT(code),GROUP_CONCAT(c.category_name) from (
select a.category_uuid uuid ,substring_index(substring_index(a.category_path,'+',b.AutoIncreID),'+',-1) as code
from
goods_category a
join
incre_table b
on b.AutoIncreID <= (length(a.category_path) - length(replace(a.category_path,'+',''))+1)
where `category_uuid` =1000
) a
LEFT JOIN goods_category c on a.code = c.category_uuid

原文地址:https://www.cnblogs.com/mytzq/p/10145729.html