SQL Statement Error - Joins

boilermaker1997

New Member
Joined
Sep 20, 2007
Messages
41
I'm trying to join several tables in an access query. One of the fields I'm joining on is formatted as a number in one table and text in another, so I'm using the Val function to make the data types match. That part of the statement work (first 4 lines shown below). I'm trying to add 2 additional joins, but I'm getting a syntax error when I try to run the query. I'm pretty inexperienced at Access so I'm not able to determine what is wrong with the syntax. Any advice is appreciated.

SQL Code

SELECT *
FROM
(Table1 INNER JOIN Table2
ON Table1.PPL_DEPT = Val(Table2.DEPT))
Table1 LEFT JOIN Table3 ON Table1.FUNCTION = Table3.Function) LEFT JOIN Table4 ON Table1.PPL_EMAIL = Table4.[e-Mail];
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Cross-posted: SQL Statement Error - Joins

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #10 here: Forum Rules).

This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

For a more complete explanation on cross-posting, see here: Excelguru Help Site - A message to forum cross posters).
 
Upvote 0
Regarding your question:

SELECT *
FROM
(Table1 INNER JOIN Table2
ON Table1.PPL_DEPT = Val(Table2.DEPT))
Table1 LEFT JOIN Table3 ON Table1.FUNCTION = Table3.Function) LEFT JOIN Table4 ON Table1.PPL_EMAIL = Table4.[e-Mail];

What is the "Table1" reference I highlighted in red supposed to be?
If it is supposed to be an alias for the code in between the parentheses, I would recommend using a different name than the name of one of the existing tables. That could be causing confusion further in the code, in which Access may not be able to tell whether to treat Table1 as an Alias or a specific Table Name.

Also, a recommendation when dealing with nested code, or code involving multiple tables. Start simple, test your code, and then add your next table, test your code, etc. So start small and build your way up. It will help you identify when and where your errors are occurring.
 
Upvote 0
Answer posted in other forum re unmatched parentheses.
 
Upvote 0

Forum statistics

Threads
1,221,614
Messages
6,160,839
Members
451,673
Latest member
wella86

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