Sql 关于加入 2 的查询 select

Sql query about joining 2 select

我想知道如何加入 2 个 select 语句,如下所示:

Select Team.name from Team join Match on Team.id == Match.teamHomeid
Select Team.name from Team join Match on Team.id == Match.teamAwayid

我得到的错误是因为我没有主队和客队的单独 ID

提前致谢

您可以多次使用同一个 table。即:

Select t1.Name as HomeTeam, t2.Name as AwayTeam 
from Match m
inner join Team t1 on t1.Id = m.teamHomeId
inner join Team t2 on t2.Id = m.teamAwayId