SELECT a.*,IFNULL(r.count,0) from (SELECT act_id,poster_id,type,style_type,status,status_time,title,content,images,start_time,end_time,district_id,address,lon_map,lat_map,person_num,person_name,person_phone,person_wx_id,reward_min,reward_max,cost_type,meal_svc,taxi_svc,hair_length,hair_handle,remark,is_over,create_time,note
FROM activity WHERE poster_id = 3055808629673784641 ORDER BY create_time DESC limit 0,20) a LEFT JOIN (SELECT count(1) count,act_id
FROM activity_user u
where u.user_status in ('YBM', 'YTG', 'YQR')
GROUP BY u.act_id) r on a.act_id = r.act_id
2.运行结果
mysql让count为0的记录也显示出来
在mysql 下执行如下命令
select use_city,count(*) from data where os="Windows 2003 Std" group by use_city;