Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query not returning all rows 2

Status
Not open for further replies.

bmc1234

Programmer
Jul 21, 2005
50
US
I have a query being used for a report and it is not returning all the rows that I want it to. Here is the sql statement:

Code:
SELECT repairdata.*, products.*, contract.*, customer.*
FROM Products INNER JOIN (RepairData INNER JOIN (Customer INNER JOIN Contract ON Customer.OwnerName = Contract.Owner) ON RepairData.ContractID = Contract.ContractID) ON Products.ProductID = RepairData.ProductID;

That was generated by access's query builder with a few changes by me, but the nested joins are confusing me so I don't fully understand what it means. The main table is repairdata but it is not returning rows that have a blank field for contractID. All I'm trying to do is return fields from repairdata and a few linked fields from other tables. Does anybody know how to do this? Thanks.
 
Code:
select RepairData.*
     , Products.*
     , Contract.*
     , Customer.*
  from RepairData
left outer
  join Products
    on Products.ProductID = RepairData.ProductID
left outer
  join Contract    
    on Contract.ContractID = RepairData.ContractID
left outer
  join Customer 
    on Customer.OwnerName = Contract.Owner

r937.com | rudy.ca
 
JetSQL syntax:
SELECT RepairData.*, Products.*, Contract.*, Customer.*
FROM ((RepairData
LEFT JOIN Products ON RepairData.ProductID = Products.ProductID)
LEFT JOIN Contract ON RepairData.ContractID = Contract.ContractID)
LEFT JOIN Customer ON Contract.Owner = Customer.OwnerName

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top