<!--{eval $mtags = DB::fetch_all("SELECT a.tagid, a.tagname, count(b.tagid) as tag_count FROM ".DB::table("common_tag")." a LEFT JOIN ".DB::table("common_tagitem")." b on b.tagid=a.tagid WHERE a.`status` = 0 group by b.tagid ORDER BY a.`tagid` DESC LIMIT 0,100");}-->
<div class="fmtags">
<!--{loop $mtags $mtag}-->
<!--{if $mtag[tag_count]>0}-->
<a href="misc.php?mod=tag&id=$mtag[tagid]" target="_blank" class="xi2">$mtag[tagname]{$mtag[tag_count]}</a>
<!--{/if}-->
<!--{/loop}-->
</div>
復(fù)制代碼
如果要按標(biāo)簽相關(guān)帖子數(shù)來排序,ORDER BY `tag_count`。
簡單描述:
查詢tag的兩個表common_tag和common_tagitem,獲取tagid,tagname兩個字段,并統(tǒng)計(jì)tagid個數(shù),分組合計(jì),按tagid倒序排序,取前100條。