4

I am trying to understand why my query(below) displays an error message in MS Access Sql query editor(sqlview) when I run it.

SELECT *
FROM tblUSPS
INNER JOIN   tblProductUSPS 
ON tblProductUSPS.[PRODUCTUSPS_USPS] = tblUSPS.[USPS_CODE] 
INNER JOIN  tblAttribute 
ON tblUSPS.USPS_ID = tblAttribute.ATTRIBUTE_USPSID

As far as I know the script below if I delete either of the INNER join lines. For instance, this script runs with no errors

SELECT *
FROM tblUSPS
INNER JOIN   tblProductUSPS 
ON tblProductUSPS.[PRODUCTUSPS_USPS] = tblUSPS.[USPS_CODE] 

And so does this

SELECT *
FROM tblUSPS  
INNER JOIN  tblAttribute ON tblUSPS.USPS_ID = tblAttribute.ATTRIBUTE_USPSID

But when I combine, something goes wrong and I am unable to find it so I would like some help identifying this please.

2

1 Answer 1

10

Access has strong opinions on parentheses.

SELECT *
  FROM 
(tblUSPS
INNER JOIN   tblProductUSPS 
   ON tblProductUSPS.[PRODUCTUSPS_USPS] = tblUSPS.[USPS_CODE] )
INNER JOIN  tblAttribute 
   ON tblUSPS.USPS_ID = tblAttribute.ATTRIBUTE_USPSID
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I was following the tutorial on w3schools and it did not mention that. Thanks
If you're learning SQL then I strongly recommend you do not learn it in Access. Oracle, SQL Server have free products and mySQL is completely free.
For the complete beginner, Access has the query design window that allows you to build joins with drag and drop, in addition there are a number of wizards. You can then switch to sql view to get a good idea of how to build your own queries.

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.