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;