2

I am trying to write this query in Microsoft Access SQL and for the life of me I cannot figure out the syntax error in the code.

SELECT base.study_group, base.NPI,inv.log_date AS invite_date, rec.log_date as
recieved_date, rej.log_date as reject_date
FROM CODAAC_master AS base
LEFT JOIN Pre_Log AS inv ON base.NPI = inv.NPI AND inv.tracking_event='INVA'
LEFT JOIN Pre_Log AS rec ON base.NPI = rec.NPI AND rec.tracking_event='RECA'
LEFT JOIN Pre_Log AS rej ON base.NPI = rej.NPI AND rej.tracking_event='REJA'
WHERE base.study_year = '2013'
ORDER BY base.study_group, base.NPI;

The error I get back is:

"Syntax error (missing operator) in query expression"
1
  • 5
    Use the query design window. You are short of parentheses. Access needs them on joins. Commented Mar 29, 2013 at 14:36

2 Answers 2

3

MS Access requires parentheses around multiple joins:

SELECT base.study_group, 
  base.NPI,
  inv.log_date AS invite_date, 
  rec.log_date as recieved_date, 
  rej.log_date as reject_date
FROM ((CODAAC_master AS base
LEFT JOIN Pre_Log AS inv 
  ON base.NPI = inv.NPI AND inv.tracking_event='INVA')
LEFT JOIN Pre_Log AS rec 
  ON base.NPI = rec.NPI AND rec.tracking_event='RECA')
LEFT JOIN Pre_Log AS rej 
  ON base.NPI = rej.NPI AND rej.tracking_event='REJA'
WHERE base.study_year = '2013'
ORDER BY base.study_group, base.NPI;
Sign up to request clarification or add additional context in comments.

Comments

3

You need to add parenthesis between the joins as it is essential on MS Access. (This is optional on other RDBMS)

SELECT  base.study_group, 
        base.NPI,
        inv.log_date AS invite_date, 
        rec.log_date as recieved_date, 
        rej.log_date as reject_date
FROM  ((CODAAC_master AS base LEFT JOIN Pre_Log AS inv 
            ON base.NPI = inv.NPI AND inv.tracking_event='INVA')
        LEFT JOIN Pre_Log AS rec 
            ON base.NPI = rec.NPI AND rec.tracking_event='RECA')
        LEFT JOIN Pre_Log AS rej 
            ON base.NPI = rej.NPI AND rej.tracking_event='REJA'
WHERE base.study_year = '2013'
ORDER BY base.study_group, base.NPI;

3 Comments

Thank you for your help. I added the parenthesis but now it is saying that the JOIN expression is not supported.
what version of ms access you are using/
your question is the on this MS Access 2007 Multiple Left Join, try to execute the updated statement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.