I have two tables : one table it matchs and the other is teams. In matches, I have a date, the time and two IDs (the two teams). In teams I have an ID and the name of the team. What I want to do is get the list of matchs with the names of the teams.
I know the INNER JOIN can do this but I’m not sure how … here’s what I have :
SELECT teams.name AS team1, teams.name AS team2, matchs.id, matchs.date, matchs.time
FROM matchs
INNER JOIN teams ON teams.id=matchs.team1
Obviously, all I get is the name of the team1. How can I have both team names?
Thank you
You want to do something like below. Just use aliases to differentiate the two joins and make your code more expressive.