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
 Problem in Join Query

Author  Topic 

teamjai
Yak Posting Veteran

52 Posts

Posted - 2013-05-14 : 05:12:39
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

52326 Posts

Posted - 2013-05-14 : 05:26:15
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
   

- Advertisement -