Say I have three tables that look like:
users:
id
event_registration:
id
user_id
event_id
events:
id
A user registers for an event and this registration is recorded in event_registration.
Is there a way I can calculate the count of events that a given set of users mutually share in a single MySQL statement? I figured out how to do this for two users, but I’d like to refactor
it to support X number of users (including just one user).
try
You have to adjust the number
3in thehavingclause acourding to the number ofuser_ids you are using in yourinclause.