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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Left outer join with condition
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

magmo
Aged Yak Warrior

524 Posts

Posted - 01/10/2014 :  10:21:49  Show Profile  Reply with Quote
Hi

I have the following Query...


SELECT        dbo.SPRAKBANMTEXT.SPRAK, dbo.ARTIKEL.ARTIKELNR, dbo.SPRAKBANMTEXT.ANMARKNING, dbo.ARTIKEL.TEXTNRANMSPRAKB, dbo.ARTIKEL.TEXTNRANMSPRAKO, dbo.ARTIKEL.TEXTNRBENAMN
FROM            dbo.ARTIKEL LEFT OUTER JOIN
                         dbo.SPRAKOANMTEXT ON dbo.ARTIKEL.TEXTNRANMSPRAKO = dbo.SPRAKOANMTEXT.TEXTNRANMSPRAKO LEFT OUTER JOIN
                         dbo.SPRAKBANMTEXT ON dbo.ARTIKEL.TEXTNRANMSPRAKB = dbo.SPRAKBANMTEXT.TEXTNRANMSPRAKB



My issue is that I need to have a left outer join on SPRAKBANMTEXT, to get the rows I need but in the same time have a condition which is... If there is a ARTIKEL.TEXTNRANMSPRAKB AND It match dbo.SPRAKBANMTEXT.TEXTNRANMSPRAKB I need to filter based on SPRAKBANMTEXT.SPRAK = "GB"


How can I do that?

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 01/10/2014 :  23:57:49  Show Profile  Reply with Quote
it should be this

SELECT        dbo.SPRAKBANMTEXT.SPRAK, dbo.ARTIKEL.ARTIKELNR, dbo.SPRAKBANMTEXT.ANMARKNING, dbo.ARTIKEL.TEXTNRANMSPRAKB, dbo.ARTIKEL.TEXTNRANMSPRAKO, dbo.ARTIKEL.TEXTNRBENAMN
FROM            dbo.ARTIKEL LEFT OUTER JOIN
                         dbo.SPRAKOANMTEXT ON dbo.ARTIKEL.TEXTNRANMSPRAKO = dbo.SPRAKOANMTEXT.TEXTNRANMSPRAKO LEFT OUTER JOIN
                         dbo.SPRAKBANMTEXT ON dbo.ARTIKEL.TEXTNRANMSPRAKB = dbo.SPRAKBANMTEXT.TEXTNRANMSPRAKB
                         AND dbo.SPRAKBANMTEXT.SPRAK = 'GB'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 01/10/2014 :  23:58:31  Show Profile  Reply with Quote
Here's explanation on the same
http://weblogs.sqlteam.com/jeffs/archive/2007/05/14/criteria-on-outer-joined-tables.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

magmo
Aged Yak Warrior

524 Posts

Posted - 01/11/2014 :  03:10:25  Show Profile  Reply with Quote
Thank you very much for the code and the explanation!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 01/11/2014 :  04:54:35  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
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.14 seconds. Powered By: Snitz Forums 2000