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.
| Author |
Topic |
|
Miki
Starting Member
5 Posts |
Posted - 2010-06-10 : 14:18:59
|
| By running the below script, I am expecting to see some NULL values, but not. Do i have to add anything to show up NULL here? Please suggest.select distinct l.loanid,l.soldto, a.name from loan lleft join acquiredfrom a on l.soldto=a.code where l.soldto not in('023', '028', '029','049', '052', '053', '054', '055', '057', '058', '059', '061', '063', '065', '066', '067', '068', '069', '070','074',)order by soldto |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-06-10 : 14:24:38
|
| Just add "soldto IS NULL" in the where condition.Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-06-10 : 20:05:38
|
| Two things to remember: 1) The WHERE clause has to evaluate to TRUE in order for a result to be generated 2) NULL essentially means that you don't know the valueSo when l.SoldTo is Null you don't know its value so you can't say that it is IN the list of values so the WHERE clause can't evaluate to True. This also means that you don't know if it is NOT IN the list so the WHERE clause can't evaluate to True.From a Boolean standpoint this doesn't make sense - Something is either IN or NOT IN. It can't be BOTH and it can't be NEITHER.SQL, however, is NOT Boolean. A logical statement can be True, False or Unknown. Not True is False; not False is True but not Unknown is still Unknown.=======================================A couple of months in the laboratory can save a couple of hours in the library. -Frank H. Westheimer, chemistry professor (1912-2007) |
 |
|
|
|
|
|
|
|