以下代码有效,但是我有一个tblRecPlayers,其中包括1个需要包含在查询中的播放器。 tblRecplayers还包括PlayerID,PlayerFirst和PlayerLast字段,如何将tblRecPlayers和tblCompPlayers结合在一起?
select
TeamName as 'Team Name',
PlayerFirst as 'First Name',
PlayerLast as 'Last Name',
tblCompPlayers.PlayerID
from
tblCompPlayers inner join
tblTeamRoster inner join
tblTeams on tblTeamRoster.TeamID = tblTeams.TeamID
on tblCompPlayers.PlayerID = tblTeamRoster.PlayerID
where
TeamName = 'Avalanche';
我认为您可能很接近...没有表结构...这只是一个猜测。但是看来您必须移动第二个ON子句。
select
TeamName as 'Team Name',
PlayerFirst as 'First Name',
PlayerLast as 'Last Name',
tblCompPlayers.PlayerID
from
tblCompPlayers inner join
tblTeamRoster on tblCompPlayers.PlayerID = tblTeamRoster.PlayerID inner join
tblTeams on tblTeamRoster.TeamID = tblTeams.TeamID
where
TeamName = 'Avalanche';
请注意对于要加入的每个其他表重复的语法:
INNER JOIN table2 ON table1.column_name = table2.column_name