MySql查询字符串分割转多行

使用MySQL将查询的字符串分割转为多行

select 
	b.help_topic_id + 1 as id, 
	substring_index(substring_index(a.name, ',', b.help_topic_id + 1) ,',', -1) as name
from
	(select 'wo,shi,xiao,ming' name) as a join mysql.help_topic b
	on 
	b.help_topic_id < LENGTH(a.name) - LENGTH(REPLACE(a.name,',','')) + 1;

你可能感兴趣的:(java,mysql,sql)