0

I have attached the 3 tables I have below.

Trainers table

enter image description here

TrainerPlan Table

enter image description here

FitnessPlans Table

enter image description here

So what I am trying to do is show the FirstName, LastName, Phone, and Hours of all trainers who have a particular PlanID. So I tried

SELECT FirstName, LastName, Phone, Hours
FROM TRAINERS T INNER JOIN TRAINERPLAN TP
ON T.ID = TP.TrainerID
INNER JOIN FITNESSPLANS FP
ON TP.PlanID = FP.ID
WHERE FP.ID = 1;

I get the error:

enter image description here

What am I doing wrong? I have done sql in sql developer and this is how I would do it. I'm pretty sure access sql is not exactly the same, but if I run:

SELECT FirstName, LastName, Phone, Hours
FROM TRAINERS T INNER JOIN TRAINERPLAN TP
ON T.ID = TP.TrainerID;

This runs successfully and shows results, so I know the inner joining is working, but I just can't get another inner join on there for some reason.

  • Access has some funky syntax requirements which force you to parenthesize multiple joins. [See here](http://stackoverflow.com/a/7855015/621962) – canon Nov 11 '13 at 18:40
  • Set up your joins in Design View of the Access query designer. It will add the required parentheses for you. – HansUp Nov 11 '13 at 18:46
  • Yet another reason why I loathe MS Access – William Jul 31 '15 at 16:44

1 Answers1

1

Access "nests" joins, which requires that they be in parentheses:

SELECT FirstName, LastName, Phone, Hours
FROM ((TRAINERS T INNER JOIN TRAINERPLAN TP
ON T.ID = TP.TrainerID)
INNER JOIN FITNESSPLANS FP
ON TP.PlanID = FP.ID)
WHERE FP.ID = 1;
D Stanley
  • 149,601
  • 11
  • 178
  • 240