mysql 字符串转多行数据


数据存储为 

 

 

 实现效果

 

 

 sql:

SELECT
    a.id,
    a.code,
    SUBSTRING_INDEX( SUBSTRING_INDEX( a.monitor_content, ',', b.id + 1 ), ',',- 1 ) AS ids 
FROM
    process_monitoring AS a
    JOIN process_monitor_content AS b ON b.id < ( length( a.monitor_content ) - length( REPLACE ( a.monitor_content, ',', '' ) ) + 1 )
        where a.code ='4203376628674604072';
View Code

process_monitor_content 表为自增序号表

格式ID 自增大于需要分组的字段就可以

 

参考

https://www.cnblogs.com/JMrLi/p/11320273.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM