a表:
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 |
统计结果:
时间: 2024-11-03 21:22:30