我正在尝试使用多个连接来创建atable,但我得到的输出/表格相同

时间:2015-10-17 12:43:29

标签: sql join alias

select 
    Date, Home, Away, Umpire 
from 
    Match
join 
    Team on Match.Home = Team.TeamId 
join 
    Team as T on Match.Away = T.TeamId
join 
    Umpire on Match.Umpire = Umpire.UmpireId

我首先尝试将TeamUmpire表与Match联系起来,因为我使用了Team两次而收到错误,所以我创建了一个别名{ {1}}。但是当我执行此操作时,我只是将T表作为输出。

您认为问题是什么?

1 个答案:

答案 0 :(得分:0)

以防你没有得到@vkp指出的内容:

select 
    Match.*, Team.*, T.*, Umpire.* 
from 
    Match
join 
    Team on Match.Home = Team.TeamId 
join 
    Team as T on Match.Away = T.TeamId
join 
    Umpire on Match.Umpire = Umpire.UmpireId