473,474 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multiple JOIN in Access

code green
1,726 Recognized Expert Top Contributor
I cannot get the following query correct. Please can somebody put me right
Expand|Select|Wrap|Line Numbers
  1. SELECT [Order Number],[Date Ordered] FROM [Order] 
  2. INNER JOIN [OrderDetail] ON [OrderDetail].[OrderSequenceNumber] = [Order].[Order Sequence Number]
  3. INNER JOIN [PaymentHistory] ON [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number]
  4. INNER JOIN [Person] invoice ON [Person].[ContactID] = [Order].[InvoiceContactID]
  5. INNER JOIN [Person] deliver ON [Person].[ContactID] = [Order].[DeliverContactID]                        
  6. WHERE [Order].[Order Sequence Number] > 88950
  7. ** Throws the error Syntax error Missing Operator **
I have also tried the "nested" idea but this also fails
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM [Order]
  2. INNER JOIN ((([OrderDetail] 
  3. INNER JOIN [PaymentHistory] 
  4. INNER JOIN [Person] ON [Person].[ContactID] = [Order].[InvoiceContactID])
  5. ON [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number])
  6. ON [OrderDetail].[OrderSequenceNumber] = [Order].[Order Sequence Number])
  7. ON [Order].[Order Sequence Number] > 88950 ** Throws the error Syntax error in From clause **[/
I have fiddled with the bracket arrangement but this has me beaten.
Thanks
Jul 5 '07 #1
5 2296
FishVal
2,653 Recognized Expert Specialist
SELECT [Order Number],[Date Ordered] FROM [Order]
INNER JOIN [OrderDetail] ON [OrderDetail].[OrderSequenceNumber] = [Order].[Order Sequence Number]
INNER JOIN [PaymentHistory] ON [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number]
INNER JOIN [Person] invoice ON [Person].[ContactID] = [Order].[InvoiceContactID]
INNER JOIN [Person] deliver ON [Person].[ContactID] = [Order].[DeliverContactID]
WHERE [Order].[Order Sequence Number] > 88950

SELECT * FROM [Order]
INNER JOIN ((([OrderDetail]
INNER JOIN [PaymentHistory]
INNER JOIN [Person] ON [Person].[ContactID] = [Order].[InvoiceContactID])
ON [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number])
ON [OrderDetail].[OrderSequenceNumber] = [Order].[Order Sequence Number])
ON [Order].[Order Sequence Number] > 88950

Hi!
The problem parts I've found are bolded.
Jul 5 '07 #2
code green
1,726 Recognized Expert Top Contributor
Yes, but I don't know what the problem is.
Jul 6 '07 #3
FishVal
2,653 Recognized Expert Specialist
Yes, but I don't know what the problem is.
Syntax problem. Why not to use query builder to build SQL statement?
Jul 6 '07 #4
code green
1,726 Recognized Expert Top Contributor
Because the query builder is for wimps.
No, I cannot use the query builder because there are no 'relationships' between the tables so JOINs fail.
And before you start it is not my database.
However the query works this way.
It may not be exactly what I wanted but at least it runs
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM [Order],[OrderDetail],[PaymentHistory],[Person]
  2. WHERE [Order].[Order Sequence Number] > 88950
  3. AND [Person].[ContactID] = [Order].[InvoiceContactID]
  4. AND [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number]
  5. AND [OrderDetail].[OrderSequenceNumber] = [Order].[Order Sequence Number]
I suppose my question should be
WHAT IS THE SYNTAX TO JOIN THREE TABLES IN ACCESS?
I can do this many ways in other SQL but not Access
Jul 6 '07 #5
FishVal
2,653 Recognized Expert Specialist
Because the query builder is for wimps.
No, I cannot use the query builder because there are no 'relationships' between the tables so JOINs fail.
And before you start it is not my database.
However the query works this way.
It may not be exactly what I wanted but at least it runs
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM [Order],[OrderDetail],[PaymentHistory],[Person]
  2. WHERE [Order].[Order Sequence Number] > 88950
  3. AND [Person].[ContactID] = [Order].[InvoiceContactID]
  4. AND [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number]
  5. AND [OrderDetail].[OrderSequenceNumber] = [Order].[Order Sequence Number]
I suppose my question should be
WHAT IS THE SYNTAX TO JOIN THREE TABLES IN ACCESS?
I can do this many ways in other SQL but not Access
Oh ye. Access is whole for whimps. A brave one likes difficulties.

Relationships are needed to let query builder make joins itself, user is welcome to draw its own, I hope at least you've determined what are the relationships between tables mentioned. As for me I prefer to let Access deal with all these nested brackets his way as he likes it.
Jul 6 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with...
4
by: Ben | last post by:
I believe I am missunderstanding how subqueries work. I simple subquery works fine but when I wish do compare 2 or more fields at once I don't get the results I wish. Table A...
5
by: Sami | last post by:
I can create queries and reports based on info from one table. How do I create one using information from multiple tables. What do I need to make sure the information from one table will be...
3
by: mkjets | last post by:
I have worked for hours on trying to find a solution and have not figured it out. I am working in Access 2003. I need to create a query that takes values from 1 table and displays them in...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
5
by: jim | last post by:
Hi, I've browsed several posts, but still haven't found the answer I'm looking for. I have one table (A) that contains a list of values I want to return. I have two other tables (B) and (C)...
0
by: SamKhazary | last post by:
I have created a database that has a main table with a description of different products. I have 5 other data bases that are linked sheets that have returns for the 5 different prduct groups. I'd...
2
ntxsoft
by: ntxsoft | last post by:
Hello everybody, I have a problem while I am trying to execute multiple query in a statement. My query like that DROP TABLE IF EXISTS query; CREATE TEMPORARY TABLE query SELECT...
4
by: AXESMI59 | last post by:
I created a query in the Access Query Builder that I modified to use with VBA Code so I could reuse it for any record I choose. The one that I created with the Access Query builder works beautifully...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.