There were problems with this SQL query. Here's the situation:
I have three tables structured as follows:
Events -> fields ID and Name,
Players -> fields ID and Name,
Matches -> fields ID, EventID, Player1ID, Player2ID
I would like to execute a query that shows me a match table, but replaces EventID with Event.Name, Player1ID with Players.Name and Player2ID with Players.Name.
It's easy for me to get one player and an event using this:
SELECT
Players.Name as Player1, Events.Name
FROM
(Matches
INNER JOIN
Events ON (Matches.EventID=Events.ID))
INNER JOIN
Players ON (Matches.Player1ID = Player.ID) ;
But how do I get the name Player2?
source
share