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
 SQL NULL VALUES

Author  Topic 

cutepraba
Yak Posting Veteran

53 Posts

Posted - 2009-09-03 : 04:11:09
select job.*, wt.desc from job, wt where job.wtid=wr.id

sometimes job.wtid can be NULL, please give me the solution to handle it.

____________
Praba

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-09-03 : 04:23:26
select job.*, wt.desc
from job LEFT JOIN wt ON job.wtid = wt.id
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-03 : 04:32:51
With that bad data maybe you want to use FULL OUTER JOIN to see non matching rows from both tables?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-09-03 : 11:36:28
job.wtid can be NULL, so how do you want to handle it? Ignore nulls? Replace nulls???? Maybe some sample data an expected output would help?
[url]http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx[/url]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-04 : 02:03:43
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/12/24/null-on-joined-columns.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -