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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Joining three tables

Author  Topic 

maddyslayer
Yak Posting Veteran

57 Posts

Posted - 2012-03-19 : 16:24:26
I need the query joining three tables. Three tables are UtilityIndustry, UtilitySubIndustry, UtilityRegStatus.

Columns in Utility Industry are Industryid and Utilityid
Columns in UtilitySubIndustry are Industryid, Subindustryid and Regstatusid
Columns in UtilityRegStatus are Regstatusid, Subindustryid and Statustype.

How do i get all the records from the table Utility Industry with Statustype='3'?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-03-19 : 16:28:46
Show us what you have so far.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-19 : 16:30:48
simple join involving all tables on related column with a where condition for your filter will give you required data

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

Go to Top of Page

sqllearner05
Starting Member

9 Posts

Posted - 2012-03-20 : 06:27:03
below is join of 3 tables.. modify it according to ur requirement

SELECT UI.*
FROM UtilityIndustry UI
INNER JOIN UtilitySubIndustry USI
ON UI.Industryid = USI.Industryid
INNER JOIN UtilityRegStatus URS
ON USI.Subindustryid = URS.Subindustryid
AND USI.Regstatusid = URS.Regstatusid
WHERE UI.Statustype = '3'

sqllearner
Go to Top of Page

maddyslayer
Yak Posting Veteran

57 Posts

Posted - 2012-03-20 : 10:36:00
Thank You

quote:
Originally posted by sqllearner05

below is join of 3 tables.. modify it according to ur requirement

SELECT UI.*
FROM UtilityIndustry UI
INNER JOIN UtilitySubIndustry USI
ON UI.Industryid = USI.Industryid
INNER JOIN UtilityRegStatus URS
ON USI.Subindustryid = URS.Subindustryid
AND USI.Regstatusid = URS.Regstatusid
WHERE UI.Statustype = '3'

sqllearner

Go to Top of Page
   

- Advertisement -