I have a table of groups:
- id — a unique ID (primary key)
- group — a group name
I have a table of users:
- username — a unique string (primary key)
- group_id — a foreign key link to group.id
In this case, a user is only going to be in one single group. So, in MySQL, how do I list out groups and their count of member users?
I tried using a subselect and count, but it ends up showing the same count on all groups.
You can use a LEFT JOIN instead if you want to display empty groups per @Michael’s comment