Nick O'Hare
Nick O'Hare

Reputation: 11

Sql query in MS Access producing Syntax error

I'm having trouble with a query in MSAccess. The code is shown below:

SELECT CustomerId, FirstName, Surname, DateOfBirth, WorkoutId, Name, Description
   FROM Customer 
   INNER JOIN (Registration INNER JOIN TrainingProgram (INNER JOIN WorkOutPlan)) 
   ON Customer.CustomerId = Registration.CustomerId 
   ON Registration.CustomerId = TrainingProgram.CustomerId 
   ON TrainingProgram.WorkId = WorkOutPlan.WorkId
      WHERE DateOfBirth > #01/01/83#;

The database has been created for a fictional gym.

The aim of the query is to show what workout plan members are on with a date of birth greater that 01/01/83. The information the query is selecting is coming from 3 Tables. Customer, TrainingProgram and WorkOutPlan. The other table 'Registration' links the Customer Table and Training Program table with 'CustomerId'

The query is producing a syntax error and highlighting the bracket '"("INNER JOIN WorkOutPlan))'. I cant see any issues with the code but maybe I have made a mistake along the way?

Your help would be much appreciated.

Upvotes: 1

Views: 92

Answers (1)

RichardTheKiwi
RichardTheKiwi

Reputation: 107826

Bracket properly

SELECT CustomerId, FirstName, Surname, DateOfBirth, WorkoutId, Name, Description
FROM (Customer 
INNER JOIN (Registration
            INNER JOIN (TrainingProgram
                        INNER JOIN WorkOutPlan 
                                   ON Customer.CustomerId = Registration.CustomerId )
                        ON Registration.CustomerId = TrainingProgram.CustomerId )
            ON TrainingProgram.WorkId = WorkOutPlan.WorkId)
WHERE DateOfBirth > #01/01/83#;

Upvotes: 3

Related Questions