Reputation: 1004
I got two tables...
fixtures
and teams
Now I would like to display the names of both teams (lteam and vteam) playing against each other in a table. I have tried to LEFT JOIN those tables, but that does not work. Guess you know why?
SELECT * FROM fixtures
LEFT JOIN teams as a ON fixtures.lteam = teams.id
LEFT JOIN teams as b ON fixtures.vteam = teams.id
WHERE date_ko = '2017-05-19'
Thanks for your help!
Upvotes: 1
Views: 435
Reputation: 31239
The joins are not correct. Change this:
LEFT JOIN teams as a ON fixtures.lteam = teams.id
LEFT JOIN teams as b ON fixtures.vteam = teams.id
|
To this:
LEFT JOIN teams as a ON fixtures.lteam = a.id
LEFT JOIN teams as b ON fixtures.vteam = b.id
|
You need to use the alias in the join too
Upvotes: 3