MySQL 字符串分隔成行&子串统计,
利用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);
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。