Mysql multiple count query results returned an error, ask for help, thank you
Table structure
- Table user (user table) is abbreviated.
- Table activity (activity table) is brief.
- Table my_calendar_subscribe (user follow activity)
id (self-added id), tempid (userid), activity (activity id)
- Table my_calendar_sign (user joining activity)
id (self-adding id), tempid (userid), activity (activity id)
Target:
- query the list of joining activities for a userid, as well as the current number of followers and participants for each activity.
question
query the list of joining activities of a userid and the current number of followers for each of them
select
a.activity,
count(sub.activity) now_sub
from
my_calendar_sign a
left join
my_calendar_subscribe sub
on
a.activity = sub.activity
where
a.tempid = 6
group by
a.activity
-result OK
userid
---OK
userid
---NOK
can"t repeat the same field of group by,
, and why is there a problem with only one of the result rows?
ask for help, thank you