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 去重復函數

查詢結果:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM