[英]sortable tag lists, in terms of popularity?
我想实现一个标签列表,例如,网站中使用的前十个标签。 是否有任何教程或文章可以帮助我实现这一目标!
例如:
#topic (200 mentions)
#topic (150 mentions)
#topic (50 mentions) ....
等等..
我假设您有一个表格tags
, posts
和posts_tags
(您尚未告诉我们要标记的内容...)来关联它们
然后,您要计算使用标签的次数:
select count(*)
from `posts_tags` pt
inner join `tags` t
on pt.tagid = t.tagid
group by t.tagid
order by count(*) desc
limit 10
如果没有更多信息,这完全是猜测,因为缺少信息,但是如果您根据系统自定义信息,这就是应该执行的查询。
SELECT tag, (
SELECT count(*)
FROM mentions
WHERE tags.id = mentions.tags_id
) as count
FROM tags
ORDER BY count DESC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.