留备
原数据 | id | name |
1 | 张三,李四,王二 | |
2 | zhangsan,lisi,wanger | |
目标数据 | id | name |
1 | 张三 | |
1 | 李四 | |
1 | 王二 | |
2 | zhangsan | |
2 | lisi | |
2 | wanger |
select t.id,
substring_index(substring_index(t.name,',',t1.help_topic_id+1),',',-1) name
from zq.test t
inner join mysql.help_topic t1
on t1.help_topic_id < (length(t.name) - length(replace(t.name,',','')) + 1);