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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join problem

Status
Not open for further replies.

mrsbean

Technical User
Jul 14, 2004
203
US
If I join only two of the three tables, I get results. There is a common set of results -- ProductID present in all three tables that should come up as a result. When I join the three tables together, I don't get any results. Can somebody help me?

SELECT tblVehicle_Product.*, tblProduct.*, tblProdDetailLeafSprings.*
FROM (tblProduct INNER JOIN tblVehicle_Product ON tblProduct.ProductID = tblVehicle_Product.ProductID) INNER JOIN tblProdDetailLeafSprings ON tblProduct.ProductID = tblProdDetailLeafSprings.ProductID;

Thanks in advance.

MrsBean
 
Try this
Code:
SELECT tblVehicle_Product.*,
       tblProduct.*,
       tblProdDetailLeafSprings.*
FROM tblProduct
LEFT JOIN tblVehicle_Product
        ON tblProduct.ProductID = 
           tblVehicle_Product.ProductID

LEFT JOIN tblProdDetailLeafSprings
        ON tblProduct.ProductID = 
           tblProdDetailLeafSprings.ProductID

The only reasons I can think of is that one of the tables does not have any rows; or none of the ProductIDs in one of the tables matches any ProductID in tblProduct.

When you say "..ProductID present in all three tables..." do you mean that all three tables have a column named ProductID; or do you mean that you know for sure that all of the values for ProductID in all of the rows in tblProduct are also present in the other two tables?

 
Okay. Blonde moment. There were no matching records in one of the tables. I was just sure they were present, but they weren't. Thanks for your help.

MrsBean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top