mysql根据指定指定字符拆分某个字段,分割成多条记录
SELECT DISTINCT substring_index(substring_index(a.device_id, ',', b.help_topic_id + 1), ',',- 1) NAME FROM tb_tabrecord a JOIN mysql.help_topic b ON b.help_topic_id < (length(a.device_id) - length(REPLACE(a.device_id, ',', '')) + 1) WHERE a.tt_id =1
substring_index() -----------------mysql 拆分函数
mysql.help_topic ----------------mysql 默认自增序列表
DISTINCT---------------------------mysql 去重复函数
查询结果: