[英]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.