首页 > 数据库技术 > 详细

MySQL 字符串分隔成行&子串统计

时间:2019-07-04 09:26:11      阅读:271      评论:0      收藏:0      [点我收藏+]

利用help_topic表把字符串转换成行(分隔符号‘,‘)

 

SELECT substring_index(substring_index(a,b,c,d,e,f,g,h,,,`help_topic_id`+1),,,-1) as `id` FROM mysql.`help_topic`;

 

统计字符串每个子串出现次数(分隔符号‘,‘)

 

SELECT substring_index(substring_index(A.`column`,,,B.`help_topic_id` + 1),,,-1) AS `sub_column`,COUNT(A.`column`) AS `count`
FROM `test` A
JOIN mysql.`help_topic` B ON B.`help_topic_id` < (length(A.`column`) - length(replace(A.`column`,,,‘‘))+1)
GROUP BY substring_index(substring_index(A.`column`,,,B.`help_topic_id` + 1),,,-1);

MySQL 字符串分隔成行&子串统计

原文:https://www.cnblogs.com/cmnull/p/11127219.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!