473,545 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ 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 2303
FishVal
2,653 Recognized Expert Specialist
SELECT [Order Number],[Date Ordered] FROM [Order]
INNER JOIN [OrderDetail] ON [OrderDetail].[OrderSequenceNu mber] = [Order].[Order Sequence Number]
INNER JOIN [PaymentHistory] ON [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number]
INNER JOIN [Person] invoice ON [Person].[ContactID] = [Order].[InvoiceContactI D]
INNER JOIN [Person] deliver ON [Person].[ContactID] = [Order].[DeliverContactI D]
WHERE [Order].[Order Sequence Number] > 88950

SELECT * FROM [Order]
INNER JOIN ((([OrderDetail]
INNER JOIN [PaymentHistory]
INNER JOIN [Person] ON [Person].[ContactID] = [Order].[InvoiceContactI D])
ON [PaymentHistory].[OrderNumber] = [Order].[Order Sequence Number])
ON [OrderDetail].[OrderSequenceNu mber] = [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
2756
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 each having 3 fields each, their own PK; the FK back to the parent table; and the unique data for that table. There is a one to many relation...
4
10303
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 ID First Last Other 1 A Z 1 2 B Y 2 3 C Z 3
5
38624
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 correctly assigned to specific person from another table? Thanks.
3
30273
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 multiple fields. I don't have the option of changing the structure of the existing tables because I am importing them from a separate data source on a...
52
6273
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 variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the...
5
4085
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 table in design mode and then add the new field and set its properties. Thanks. --
5
32732
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) that may or may not include the same values, but will have others I need to include. I'd like to return all of the data from table A with a yes/no...
0
1517
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 like to have a query run and pull in all the products with their respective return. Is there a way to have it search for the same field on multiple...
2
2821
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 Separations.ID,Name,Separation_Method,OrganismID,Date,Image,Description FROM Separations; DROP TABLE IF EXISTS login; CREATE TEMPORARY TABLE login SELECT...
4
3340
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 with the hardcoded criteria. The VBA version with my criteria being set by a variable returns Error 3021. I am using a DAO Recordset and all I want...
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7664
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
720
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.