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

INNER JOIN newbie question 1

Status
Not open for further replies.

Trope

Programmer
May 14, 2001
110
US
Ok I am familiar with joining tables like this:

Select table1.name,
table1.address,
table2.productDesc,
table2.productPrice,
table3.shippingfrom
FROM table1,
table2,
table3
WHERE
table1.ID = table2.customerID AND
table1.ID = table3.customerID

That all makes perfect sense to me - BUT... how would I use the INNER JOIN feature to accomplish this same thing? It seems to get a little complicated when joining more than 2 tables.

Any help would be greatly appreciated.

Thanks!
Trope

 
Here is an example of an inner join with 3 tables. I didn't taylor it to your example, but you can get the jist of it. I don't use the inner join, because like you I think it is easier read the way you have written it. Why do you want to use inner joins?

SELECT *
FROM Vendors INNER JOIN Products
ON Vendors.vend_id = Products.vend_id
INNER JOIN Orders
ON Products.prod_id = Orders.prod_id


Dodge20
 
Try this...I'm aliasing table names here...let me know if this works...I'm assuming all the tables have a customer id field

Select a.name,
a.address,
b.productDesc,
b.productPrice,
c.shippingfrom
FROM (table1 AS a
INNER JOIN table2 AS b
ON a.ID = b.CustomerID)
INNER JOIN table3 AS c
ON a.ID = c.CustomerID;
 
Thanks! Both example helped!

I really don't want to use inner join, but I am modifying an existing app for one of my clients - and the previous developer used many inner joins.

The table aliases really made it click in. Thanks guys.

Trope
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top