问题:
将上面的数据转为下面结构
SQL:
SELECT t.D1 D, if(t.S1 = '-', null, t.S1) S
FROM (SELECT a.D D1, substring_index(substring_index(a.S, ',', b.help_topic_id + 1), ',', - 1) S1
FROM (select D, concat_ws(',', S1, S2, ifnull(S3, '-')) as S
from table_test) a
JOIN mysql.help_topic b
ON b.help_topic_id < (length(a.S) - length(REPLACE(a.S, ',', '')) + 1)
ORDER BY D) AS t;