Marco McCraft Marco McCraft - 8 months ago 61
SQL Question

Difficult MYSQL-Query

I have the following database:

And I want to count all the entries with the same

, so that I know how many players are in one team. Then i want to check if the teamsize is all ready the size of the NumbersOfMembers and if not so show me them.

The idea is, that I can see which team is not fully completed.


Fixed and tested version of Dans answer:

SELECT teamname, count(*) AS TeamSize, max(numberOfMembers) AS maxMembers 
FROM yourTable 
GROUP BY teamname 
HAVING TeamSize < maxMembers

But you should normalize your table. No need to repeat the general teamdata and restrictions for every user.