Missing operator in join query

  • Thread starter Thread starter Jon Cosby
  • Start date Start date
J

Jon Cosby

Why am I "missing an operator" here? The table and field names are okay.

SELECT PlayerGames.PlayerID, PlayerGames.Minutes, PlayerGames.Points,
Teams.TeamName, Players.TeamID
FROM Players INNER JOIN PlayerGames ON Players.PlayerID =
PlayerGames.PlayerID
INNER JOIN Games ON PlayerGames.GameNo = Games.GameNo
INNER JOIN TeamGames ON Games.GameNo = TeamGames.GameNo
INNER JOIN Teams ON TeamGames.TeamID = Teams.TeamID

WHERE PlayerGames.PlayerID="P10007" AND Players.TeamID<>Teams.TeamID;


Jon Cosby
 
Jon Cosby said:
Why am I "missing an operator" here? The table and field names are okay.

SELECT PlayerGames.PlayerID, PlayerGames.Minutes, PlayerGames.Points,
Teams.TeamName, Players.TeamID
FROM Players INNER JOIN PlayerGames ON Players.PlayerID =
PlayerGames.PlayerID
INNER JOIN Games ON PlayerGames.GameNo = Games.GameNo
INNER JOIN TeamGames ON Games.GameNo = TeamGames.GameNo
INNER JOIN Teams ON TeamGames.TeamID = Teams.TeamID

WHERE PlayerGames.PlayerID="P10007" AND Players.TeamID<>Teams.TeamID;


Jon Cosby

Jon Cosby,


SELECT PlayerGames.PlayerID
,PlayerGames.Minutes
,PlayerGames.Points
,Teams.TeamName
,Players.TeamID
FROM Players
INNER JOIN
PlayerGames
ON Players.PlayerID = PlayerGames.PlayerID
INNER JOIN
Games
ON PlayerGames.GameNo = Games.GameNo
INNER JOIN
TeamGames
ON Games.GameNo = TeamGames.GameNo
INNER JOIN
Teams
ON TeamGames.TeamID = Teams.TeamID
WHERE PlayerGames.PlayerID = "P10007"
AND Players.TeamID <> Teams.TeamID;

Access requires that () be placed around extra JOINs (beyond the first) to
indicate JOIN-order.

Example

SELECT PlayerGames.PlayerID
,PlayerGames.Minutes
,PlayerGames.Points
,Teams.TeamName
,Players.TeamID
FROM (((Players
INNER JOIN
PlayerGames
ON Players.PlayerID = PlayerGames.PlayerID)
INNER JOIN
Games
ON PlayerGames.GameNo = Games.GameNo)
INNER JOIN
TeamGames
ON Games.GameNo = TeamGames.GameNo)
INNER JOIN
Teams
ON TeamGames.TeamID = Teams.TeamID
WHERE PlayerGames.PlayerID = "P10007"
AND Players.TeamID <> Teams.TeamID;

The above saves without errors, but I was unable to test it.

Also, your order of joins may be different that the order I created.


Sincerely,

Chris O.
 
Back
Top