Rick,
Sorry to have to add to your headache and the bad taste in your mouth, but here goes.
First of all, I'd be willing to bet half my paycheck that you did not actually receive the results you said you did with the query:
SELECT COUNT(*) FROM DEPT WHERE LOC = NULL;
(You said, "This query returned count = 2 (the rows with 'TEST4' & 'TEST5' as the dept names."
Sorry, but there ain't no way in the Oracle world that you saw a count of 2 with that query. It would have to read:
SELECT COUNT(*) FROM DEPT WHERE LOC IS NULL;
...for you to see '2' as the results.
Here's an even more-interesting twist...Try this:
SELECT COUNT(*) FROM DEPT WHERE NULL = NULL;
You will see a result of '0', because NULL does NOT equal NULL; however, NULL IS NULL (and '' IS NULL) !
In Oracle, the operator '=' means (when comparing strings) "do the bits of the left operand match the bits of the right operand?" If either operand has no bits (NULL), then the result of the comparison is immediately (and by definition) "NOT TRUE"
This should make it easier to understand:
NULL is an UNKNOWN VALUE. 1) Does an UNKNOWN VALUE equal an UNKNOW VALUE? The answer is "UNKNOWN" and certainly not "TRUE". But, "IS an UNKNOWN VALUE an UNKNOWN VALUE?" Now that, unarguably is "TRUE". That is why, when checking comparing to anything that could possibly be NULL, we must ask "Is the comparand unknown?". The syntax for asking that question is "...<comparand> IS NULL..."; if you ask "...<comparand> = NULL...", then the results are not TRUE...the results are UNKNOWN (not FALSE). So in Oracle, there are three possible results to a True/False question: TRUE/FALSE/and MAYBE (read, "NULL" or "UNKNOWN"

.
So, here are results you'll see against your DEPT table, above:
SELECT COUNT(*) FROM DEPT WHERE LOC = NULL; (answer 0)
SELECT COUNT(*) FROM DEPT WHERE LOC IS NULL; (answer 2)
SELECT COUNT(*) FROM DEPT WHERE LOC = LOC; (answer 1)
SELECT COUNT(*) FROM DEPT WHERE LOC = ''; (answer 0)
SELECT COUNT(*) FROM DEPT WHERE NULL = NULL; (answer 0)
SELECT COUNT(*) FROM DEPT WHERE NULL IS NULL; (answer 3)
SELECT COUNT(*) FROM DEPT WHERE '' IS NULL; (answer 3)
Fun with logic, huh? (Let me know how you feel about all this.)
Dave
Sandy, Utah 8 Oct 03 @ 04:16 GMT (21:16 Mountain Time)