I want to select all users from the database that is not within the particular team ID I'm looking at. Trying to make an 'add a member' function which is supposed to list all members that are not in the active team.
I just can't seem to get the SQL right.. Either I get nothing, or I still get some members that are within the active team and others, which I don't want.
This is the database, IMGUR
So in this case, viewing team ID 77 on the website, I wanna see only "Admin", as he is the one member that is not within that particular team.
Any help would be much appreciated.
I think this is what you need:
SELECT * FROM User WHERE userid NOT IN ( SELECT userid FROM UserTeam WHERE teamid = ... )
It returns all users except those in the specific team.