Archives of the TeradataForum
Message Posted: Mon, 24 Sep 2012 @ 20:06:21 GMT
Subj: | | Re: In where condition 'not' and 'and is not working together |
|
From: | | Pluebell, Fred |
Your issue is 3-value logic, i.e. how NULL is handled. In particular, comparing NULL with another value (even another NULL) yields NULL as the
result. To test for NULL you must use IS NULL (or IS NOT NULL). In the example:
not(100=100 and '1'='1') -> not (True and True) -> not (True) -> False
not(NULL=100 and '1'='1') -> not(NULL and True) -> not(NULL) -> NULL; but since this is final result, treated as False
not(NULL=100 and NULL='1') -> not(NULL and NULL) -> not(NULL) -> NULL; treated as False
not(NULL=NULL and '2'='1') -> not(NULL and False) -> not(False) -> True
|