2

I'm getting stuck trying to create a count of occurrences of every Filename from MainTable in myQuery. With Access (yes I know) complaining about a missing operator in the first join, which does work if I remove the second.

I did try to simplify this to cut down on reading. As far as I can there isn't a missing operator. Let me know if there's a better way to do this or if you can spot the problem.

    SELECT DISTINCT
      mainTable.Filename,
      mainTable.Link,
      otherTable.Field,
      qryC.Total           
    FROM mainTable
    LEFT JOIN otherTable
      ON mainTable.number = otherTable.position_nbr
    LEFT JOIN 
      (SELECT Filename, Count(*) As 
         Total FROM otherQuery
         GROUP BY Filename
       ) As qryC
      ON mainTable.Filename = qryC.Filename
    WHERE (((mainTable.Filename) IS NOT NULL
    OR (mainTable.Filename) <> ""));

1 Answer 1

2

MS Access needs parentheses in the FROM clause:

FROM (mainTable LEFT JOIN
      otherTable
      ON mainTable.number = otherTable.position_nbr
     ) LEFT JOIN 
     (SELECT Filename, Count(*) As Total
      FROM otherQuery
      GROUP BY Filename
     ) As qryC
     ON mainTable.Filename = qryC.Filename
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I've been trying to figure out why this was happening for about an hour and half. I hate that this is the answer

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.