原始数据格式如下:
处理结果:
SQL:
SELECT
substring_index( substring_index( a."字段名", ',', b.help_topic_id + 1 ), ',',- 1 ) AS result
FROM
"表名" a
JOIN mysql.help_topic b ON b.help_topic_id < ( length( a."字段名" ) - length( REPLACE ( "字段名", ',', '' ) ) + 1 )
GROUP BY
result
JOIN 关联表
SELECT
substring_index( substring_index( a."字段名1", ',', b.help_topic_id + 1 ), ',',- 1 ) AS result
FROM
"表名1" a
JOIN mysql.help_topic b ON b.help_topic_id < ( length( a."字段名1" ) - length( REPLACE ( "字段名1", ',', '' ) ) + 1 )
JOIN "表名2" c
JOIN mysql.help_topic d ON d.help_topic_id < ( length( c."字段名2" ) - length( REPLACE ( c."字段名2", ',', '' ) ) + 1 )
JOIN "表名3" m ON a."字段名2" = m."字段名3"
WHERE
"条件"
GROUP BY
result
请替换代码中的 "表名" 、"字段名" 、"条件"
*注意:执行SQL需要开启 mysql.help_topic 表的 读权限