一、具体原理请看:https://www.jb51.net/article/206106.htm
二、直接上需求和sql语句
需求:将下面表a的一列ids按照分号 ; 拆分,表内容如图
sql语句拆分:
select
substring_index(substring_index(a.ids,';',mysql.help_topic.help_topic_id+1),';',-1) as num
from
a
join
mysql.help_topic
on
mysql.help_topic.help_topic_id < LENGTH(a.ids)-LENGTH(replace(a.ids,';','')+1)
结果:
不想理解原理的直接将表a和要拆分的列ids替换即可,其他不变。