Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Triple Join?

Author  Topic 

DJJUBES
Starting Member

4 Posts

Posted - 2012-05-20 : 16:22:28
Hi there

I have the following query:

I would like to know the Name of the
Company, the Contact Person linked to the company, the product ID linked to the company’s products, the products that the supplier supplies, the price of each product,
and finally the quantity of the products in stock.
The results that needs to be displayed are as follows, CompanyName, ContactName, ProductID, ProductName, UnitPrice, Quantity.

It seems to me that a triple join of some kind is needed to answer such a query, how does one join three tables?

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-20 : 16:52:39
can you please provide sample data of your requirement ad desired output?

Vijay is here to learn something from you guys.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-20 : 17:32:23
just like

select columns...
from table1 t1
inner join table2 t2
on t2.relatedfield = t1.relatedfield
inner join table3 t3
on t3.relatedfield = t2.relatedfield
..


just put the correct table names and correct set of columns by which they're related and you're good to go!

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -