0

I have been struggling with various syntax errors on a query in MS Access that works fine in TSQL.

For example, I learned that MS Access requires parentheses when there are more than one left/inner joins, and also if there is more than one ON condition for any of those joins, thanks to this post and this post.

However, I am now stuck with another "Join expression not supported" error, when I have three ON conditions for an INNER JOIN:

SELECT *  
FROM ((
        (Table1
        INNER JOIN Table2 ON Table2.Col2 = Table1.Col2)

        LEFT JOIN Table3 
        ON (Table1.id = Table3.fid
             and Table3.Col2 > SomeNumber)
        )

        LEFT JOIN Table4 
        ON (Table4.Col2 = Table3.Col2
             and Table4.Col4 = 'SomeValue'
             and Table4.fid = Table1.x_id)
        )

The above gets the "Join expression not supported" error, but if I remove any one of the three conditions in the last LEFT JOIN ON, the SQL was fine, like this:

SELECT *  
FROM ((
    (Table1
    INNER JOIN Table2 ON Table2.Col2 = Table1.Col2)

    LEFT JOIN Table3 
    ON (Table1.id = Table3.fid
         and Table3.Col2 > SomeNumber)
    )

    LEFT JOIN Table4 
    ON (Table4.Col2 = Table3.Col2
         and Table4.fid = Table1.x_id)
    )

Any two of the three conditions was accepted in the above. I have even tried adding additional parentheses like this but it didn't work either:

    LEFT JOIN Table4 
        ON ((Table4.Col2 = Table3.Col2
             and Table4.Col4 = 'SomeValue')
             and Table4.fid = Table1.x_id)
        )

Please help - thanks!

June7
  • 19,874
  • 8
  • 24
  • 34
ltree
  • 43
  • 1
  • 1
  • 8

0 Answers0