策码兄弟

显示分类对应的文章数目,为空的设置为0,按文章数目排序

select a.id ,COUNT(b.id) as num from phphi_category a left join phphi_article b on b.cid=a.id  GROUP BY a.id order by num desc;

posted @ 2014-03-25 10:34  策码秀才  阅读(132)  评论(0编辑  收藏  举报
策码兄弟