1.字段内容
2.想得到的效果
步骤1中,每一条记录的FJ字段,根据分号,拆分成多条,如下图所示:
3.具体实现
说明:
SELECT DISTINCTsubstring_index(substring_index(a.要拆分的字段, '分隔字符', b.help_topic_id + 1), '分隔字符',- 1) as 拆分后字段别名
FROM 实际表名 aJOIN mysql.help_topic b ON b.help_topic_id < (length(a.要拆分的字段) - length(REPLACE(a.要拆分的字段, '分隔字符', '')) + 1)
WHERE a.ID = 2082894;
实现:
SELECT DISTINCTsubstring_index(substring_index(a.fj, ';', b.help_topic_id + 1), ';',- 1) as fj_id
FROM temporary_traffic_permit_info aJOIN mysql.help_topic b ON b.help_topic_id < (length(a.fj) - length(REPLACE(a.fj, ';', '')) + 1)
WHERE a.ID = 2082894;