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.

eabraham
  • 4,094
  • 1
  • 23
  • 29
Kobojunkie
  • 6,375
  • 31
  • 109
  • 164
  • Please try googling first, in this case "MS Access multiple inner joins" got me straight to what seems your problem: http://www.dbforums.com/microsoft-access/1617402-correct-syntax-inner-join-multiple-tables.html I mean honestly, SO should not be your first stop for all problems. – Stefan H Aug 10 '12 at 20:03
  • possible duplicate of [Access 2010: Syntax error (missing operator) in query expression](http://stackoverflow.com/questions/10852499/access-2010-syntax-error-missing-operator-in-query-expression) – Stefan H Aug 10 '12 at 20:07

1 Answers1

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
Fionnuala
  • 90,370
  • 7
  • 114
  • 152
  • Thanks. I was following the tutorial on w3schools and it did not mention that. Thanks – Kobojunkie Aug 10 '12 at 20:21
  • 2
    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. – Jesse Aug 10 '12 at 20:29
  • 2
    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. – Fionnuala Aug 10 '12 at 20:41