Missing operator in join query

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
 
C

Chris2

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top