现有一张表,将字段 string 的值,按英文逗号分割为行数据
select
a.id,
substring_index(
substring_index(
a.string ,
',',
b.help_topic_id + 1
),
',' ,- 1
) AS string
FROM
dt a
JOIN mysql.help_topic b ON b.help_topic_id < (
length(a.string) - length(
REPLACE (a.string, ',', '')
) + 1
)
where a.string !=''
结果为