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

 

结果

 

 

posted @ 2021-08-25 23:34  MasterC  阅读(281)  评论(0编辑  收藏  举报