This is eluding me. I am trying to pull meta data about players that I have matched against each other in a game. Eg: Player 22 vs. Player 54
I have 2 mysql tables.
Table: players (id, name, image_url, etc)
1 | John | john.jpg | etc
2 | George | george.jpg | etc
3 | Ian | ian.jpg | etc
4 | Steve | steve.jpg | etc
Table: matchups (id, left_players_id, right_players_id)
1 | 1 | 3
2 | 2 | 4
I want to display the left player image and name and the right player image and name on my web page.
SELECT m.left_players_id, p.name AS left_player, m.right_players_id, p.name AS right_player FROM players p, matchups m WHERE m.left_players_id = p.id AND m.right_players_id = p.id
0 results because of the AND (requiring a match that doesn't exist)
SELECT m.left_players_id, p.name AS left_player, m.right_players_id, p.name AS right_player FROM players p, matchups m WHERE m.left_players_id = p.id OR m.right_players_id = p.id
4 results (dupes of each row)
What am I missing?