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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Joined SQL Query for 3 tables
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

teamjai
Yak Posting Veteran

India
52 Posts

Posted - 08/25/2014 :  02:43:22  Show Profile  Reply with Quote
1)Table Name - Segementation
- ID (primary Key)
- Producttype
- Material

2) Table name- Btype
-ID (primary Key)
-Bcode

3)Table name - SegmentBrelationship
-Id (primary key)
-SegID (Foreign key) (from Table Segmentation)
-BTID (Foreign key) (from Table -Btype)
-Material

i need joined SQL query with following tables and fields would be needed for helping to cross check whether all correct materials are assigned.

My query

Select ID, ProductType,Material from segementation..

Here i need to check the BTID and Material from btype & SegmentBrelationship table..

Could you please help me. Thanks.

djj55
Constraint Violating Yak Guru

USA
352 Posts

Posted - 08/25/2014 :  14:50:18  Show Profile  Reply with Quote
select Seg.* 
from Segementation Seg 
INNER JOIN SegmentBrelationship SBR ON Seg.ID = SBR.SegID
INNER JOIN Btype BT ON BT.ID = SBR.BTID


This is not the answer but an example to help you find the answer.

djj
Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000