Reputation: 21
I am really stuck, i have 2 tables with football match data:
id, name
id, hometeam, awayteam
I have done the following:
SELECT hometeam, awayteam, score, week FROM fixture
join team on fixture.hometeam = team.id;
basically the hometeam and awayteam are id numbers that relate to the team table, but i need to output these as the actual text name.
any help would be grately appreciated
thanks :)
Upvotes: 2
Views: 1258
Reputation: 425321
SELECT th.name AS hometeam_name, ta.name AS awayteam_name, week, score
FROM fixture
JOIN team th
ON th.id = fixture.hometeam
JOIN team ta
ON ta.id = fixture.awayteam
Upvotes: 2