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
 Problem in Join Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

teamjai
Starting Member

India
44 Posts

Posted - 05/14/2013 :  05:12:39  Show Profile  Reply with Quote
SQL Query:
select Name, OrgUnitFilterActive from [dbo].[cMat_Template_KDoc_C] as A LEFT OUTER JOIN [dbo].[cMat_Template_KDoc_Text_C] as B
ON
B.TemplateGUID = A.camosGUID
and A.OrgUnitFilterActive = 1 and B.TextLanguage = '1'
JOIN [dbo].[cMat_Country_C] as C ON C.camosGUID = A.SalesOrgGIUD and C.camosGUID = 'E7E94D186E0952419FE1CE478EB95A6D'
WHERE A.Deleted = 0

OUTPUT:
Name OrgUnitFilterActive
------ ----------------------
AAA 0
BBB 0
CCC 0
DDD 0

My Question is i check the condition "OrgUnitFilterActive = 1", but i got the output is "0"

Why?

Please help me

Thanks

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/14/2013 :  05:26:15  Show Profile  Reply with Quote
you're not doing the checking as a filter but you're only applying check while doing LEFT JOIN. So still records with OrgUnitFilterActive = 0 will come without matches from other end. What you're probably looking after is this?


select Name, OrgUnitFilterActive from [dbo].[cMat_Template_KDoc_C] as A LEFT OUTER JOIN [dbo].[cMat_Template_KDoc_Text_C] as B 
ON 
B.TemplateGUID = A.camosGUID
and B.TextLanguage = '1' 
JOIN [dbo].[cMat_Country_C] as C 
ON C.camosGUID = A.SalesOrgGIUD and C.camosGUID = 'E7E94D186E0952419FE1CE478EB95A6D' 
WHERE A.Deleted = 0
and A.OrgUnitFilterActive = 1 


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
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.06 seconds. Powered By: Snitz Forums 2000