substring_index(str,delim,count)
说明:substring_index(被截取字段,关键字,关键字出现的次数)
原始是这样
拆分后
代码
SELECT
distinct
a.user_id,
substring_index(replace(replace(substring_index(substring_index(a.dept_ids,',',b.help_topic_id + 1),',' ,- 1),"{",""),"}",""),":",1) AS dept_id2
FROM
表名 a
JOIN mysql.help_topic b ON b.help_topic_id < (
length(a.dept_ids) - length(
REPLACE (a.dept_ids, ',', '')
) + 1
)