【发布时间】:2023-01-27 00:36:29
【问题描述】:
我有一个包含匹配项的表,每行包含两个外键,每个外键都引用一个单独的玩家表中的玩家。
我怎样才能选择数据,以便它在一行中返回两个玩家的完整数据,比如他们的名字和姓氏?
SELECT * FROM Matches
JOIN Players ON Matches.Player1_ID=Players.Player_ID
JOIN Players ON Matches.Player2_ID=Players.Player_ID
这行不通
【问题讨论】:
-
使用不同的表别名,例如
JOIN Players p1 ON Matches.Player1_ID=p1.Player_ID。