I'm designing a website to teach myself how to use table joins in mysql and have got stuck pretty early on. (The numbers are Wii friend codes, if that helps you make sense of this!)
I have 3 tables:
users:
id, firstname, surname
games:
id, title
numbers:
number, users_id, game_id
The number is a unique code that belongs to the user and associates with a game.
I'm trying to get out a list of numbers for a specific game along with the names of the users they belong to.
I'm running the query:
SELECT firstname, surname, number FROM games, users, numbers WHERE numbers.game_id = games.id AND games.title = 'foogame'
for instance, to get out all the numbers belonging to foogame. However, this returns any user who doesn't have a code for this game with a random code from another user. How do I make this query only return the users who actually have a code for that game?