**
mysql 根据字符串“,”。转列显示
**
原数据
转换语句
select ntp.BD_NAME , substring_index(substring_index(ntp.CAR_IDS , ',', h.help_topic_id + 1), ',', -1) as cid
from NMGZR_TRANSPORTPLAN_PLAN ntp
cross join mysql.help_topic h
where ntp.CAR_IDS is not null and ntp.CAR_IDS != '' and h.help_topic_id <(length(ntp.CAR_IDS)-length(replace(ntp.CAR_IDS,',',''))+1)
结果: