Inner Joins with multiple tables

jaybee3

Active Member
Joined
Jun 28, 2010
Messages
307
Hi All,

I'm trying to wrap my head around the syntax for Access SQL. I'm pretty sure this would normally work, I've previously only dabbled with Oracle. I read something about parentheses with Access joins but the placement of them evades me. Any help would be much appreciated.

Code:
SELECT cu.CustName, v.Date,v.Rate,v1.Date,v1.Rate</SPAN></SPAN>
FROM Value v </SPAN></SPAN>
INNER JOIN Value v1 </SPAN></SPAN>
ON v1.ID = v.ID</SPAN></SPAN>
  INNER JOIN Class c </SPAN></SPAN>
  ON c.ID = v.ID </SPAN></SPAN>
    INNER JOIN Subject s </SPAN></SPAN>
    ON s.Sub = c.Sub </SPAN></SPAN>
      INNER JOIN Customers cu </SPAN></SPAN>
      ON cu.CustNumber = s.CustNumber</SPAN></SPAN>
WHERE v.date = #02/04/2013# and v1.date = #28/03/2013# and cu.custnumber = 19;</SPAN></SPAN>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Parentheses may be helpful in nesting Inner Joins (if nothing else, for readability), but I do not think they are necessary. I usually don't use them in my Inner Joins, and they seem to work fine.

What happens when you try?
Are you getting errors or unexpected results?
 
Upvote 0
Cheers for the quick response.

It won't run, I'm getting the following error popping up

I'm getting "Syntax error (missing operator) in query expression 'v1.ID= v.ID ....


Solved the problem: For every inner join i needed a parenthesis before the initial table and one after each join:

Code:
...
FROM ((((Value v </SPAN></SPAN>
INNER JOIN Value v1 </SPAN></SPAN>
ON v1.ID = v.ID</SPAN></SPAN> )
INNER JOIN Class c </SPAN></SPAN>
  ON c.ID = v.ID )</SPAN></SPAN>
    INNER JOIN Subject s </SPAN></SPAN>
    ON s.Sub = c.Sub )</SPAN></SPAN>
      INNER JOIN Customers cu )</SPAN></SPAN>
      ON cu.CustNumber = s.CustNumber
...
</SPAN></SPAN>
 
Last edited:
Upvote 0
Odd. I have never had to do that before. But if you got it to work out, that's all the matters!
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top