目标
原数据
代码
with cte as (
select 'A+B' as A,
1 as b
UNION ALL
SELECT 'C+D' as A,
2 as b
)
SELECT A,
substring_index(substring_index(f.A, '+', (h.help_topic_id + 1)), '+', -(1)) as AA,
b
FROM cte f
join mysql.help_topic h
on h.help_topic_id < ((length(f.A) - length(replace(f.A, '+', ''))) + 1)
注:将代码中 ”+“ 修改为连接符号即可