b表:
按“分类名称”分类统计日志数和参与用户数:
SELECT b.catname AS '分类名称', COUNT( * ) AS '日志数', count( DISTINCT a.username ) AS '人数'
FROM `pre_home_blog` a
LEFT JOIN `pre_home_blog_category` b ON a.catid = b.catid
WHERE a.status =0
GROUP BY b.catid
统计结果:
除非注明,均为湛蓝天空原创,转载请注明本文网址:http://skyhome.cn/sql/144.html