我真的被困了,我有2张足球比赛数据表:
id, name
id, hometeam, awayteam
我做了以下事情:
SELECT hometeam, awayteam, score, week FROM fixture
join team on fixture.hometeam = team.id;
基本上,hometeam和awayteam是与团队表相关的id号,但是我需要输出这些作为实际的文本名。
任何帮助都会受到赞赏
谢谢:)
答案 0 :(得分:2)
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