I have a game where I have teams containing a number of users. There are different amounts of users in each team but for anyone team the combination of users makes that team unique.
I have created three database tables for this.
Team User TeamUsers
t_id u_id t_id, u_id
If users 1, 4, 5 and 7 have been in a team together previously I would like to know the team ID of that team. What would the SQL look like for this?
I have experimented with something like this:
SELECT t_id FROM teamusers WHERE u_id IN (users[1], ..., users[i])
GROUP BY t_id HAVING COUNT(t_id) = users[].length;
users
array is programatically filled with the values. Does this seem correct? Is there another way that's better?