SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Triple Join?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

DJJUBES
Starting Member

South Africa
4 Posts

Posted - 05/20/2012 :  16:22:28  Show Profile  Reply with Quote
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

India
311 Posts

Posted - 05/20/2012 :  16:52:39  Show Profile  Reply with Quote
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

India
47023 Posts

Posted - 05/20/2012 :  17:32:23  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000