有朋友问我一个统计sql,需要统计字符串的个数
SELECT substring_index( substring_index( A.`module`, ',', B.`help_topic_id` + 1 ), ',',- 1 ) AS `sub_column`, COUNT( A.`module` ) AS `count` FROM `a` A JOIN mysql.`help_topic` B ON B.`help_topic_id` < ( length( A.`module` ) - length( REPLACE ( A.`module`, ',', '' ) ) + 1 ) GROUP BY substring_index( substring_index( A.`module`, ',', B.`help_topic_id` + 1 ), ',',- 1 );
利用help_topic表把字符串转换成行(分隔符号',')
本文为Davidvivi原创文章,转载无需和我联系,但请注明来自Davidvivi博客weixia.xin 本人微信:ww646904527,备注博客