mysql tag 标签统计
数据
News表
创建个从0递增的数据表帮助查询
表名listdb
查询语句
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(tag,',',id_table.id+1),',',-1) AS tagname,count(tag) as tagname_count FROM news JOIN listdb AS id_table ON id_table.id <(LENGTH(tag)-LENGTH(REPLACE(tag,',',''))+1) GROUP BY tagname ORDER BY tagname_count desc
语句挺抽象的,理解下来费了我好大劲 o(╥﹏╥)o
结果
————勇敢的少年啊 快去创造奇迹————