I have a table called player_league that looks like this:
The userID and leagueID are foreign keys referencing columns in the users and leagues table respectively.
I want to query the database to get all the users who would have a leagueID of 1 from the player_leagues table.
SELECT leagueID from users join player_league pl WHERE pl.leagueID = 1
You're missing the
on part of the
join clause that instructs the database how to join the two tables. The default is a Cartesian Product, i.e., joining every row from the first table with every row from the second table.
In this case, you can join on the
SELECT u.* FROM users u JOIN player_league pl ON u.userID = pl.userID WHERE pl.leagueID = 1