RE: Double Joins
From: Tom Tait (tomtait_at_excite.com)
Date: 02/12/04
- Next message: DVN: "RE: Adding values in row to get a total. How to do it??"
- Previous message: TomTait: "RE: Calculating School Year"
- In reply to: Pikabu: "Double Joins"
- Next in thread: news.microsoft.com: "Re: Double Joins"
- Reply: news.microsoft.com: "Re: Double Joins"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 12 Feb 2004 11:56:06 -0800
Pik,
You have to nest queries to get this done. One top level query will pull it all together for you. Have one query called qryClient with the SQL Statement:
SELECT invoice_id,client_name FROM invoices INNER JOIN clients ON invoices.client_id=clients.client_id
and another query called qryConsign with the SQL:
SELECT invoice_id,Consign_name FROM invoices INNER JOIN clients ON invoices.client_id=clients.Consign_id
Then add both of those queries into another query called "qryFinalCall". Join the two queries on the clientid. Now you are set.
----- Pikabu wrote: -----
I have an invoices database with three fields:
Invoice_id Integer
Client_id Integer
Consignee_id Integer
I also have a clients database with two fields:
Client_id Integer
Client_name char(100)
Both the client_id and the consignee_id refer to records of the
clients table (clients and consignees are stored in the clients
table), so for each invoice I have two related records in the clients
table.
The problem I have is how to retrieve the invoice_id and the name of
both the client and the consignee using a single query.
I can use the following statement to get the invoice id and the client
name, but how do I retrieve the consignee name in the same select?
SELECT invoice_id,client_name FROM invoices INNER JOIN clients ON
invoices.client_id=clients.client_id
Thanks for any help!
Luis
- Next message: DVN: "RE: Adding values in row to get a total. How to do it??"
- Previous message: TomTait: "RE: Calculating School Year"
- In reply to: Pikabu: "Double Joins"
- Next in thread: news.microsoft.com: "Re: Double Joins"
- Reply: news.microsoft.com: "Re: Double Joins"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|