I have the following query:
SELECT apps.Field4,
ISNULL(apps.field4, '-1')
FROM applications apps
WHERE apps.OBJECT_ID = 1727847
AND ISNULL(apps.Field4, -1) = -1
apps.field4
is an integer, and no record has a value less than 0 for field4
.
The return values for the above query are:
+------+----+
| NULL | -1 |
+------+----+
But if I add AND apps.field4 is NULL
to the where clause, no records are returned:
SELECT apps.Field4,
ISNULL(apps.field4, '-1')
FROM applications apps
WHERE apps.OBJECT_ID = 1727847
AND apps.field4 IS NULL
AND ISNULL(apps.Field4, -1) = -1
Why does ISNULL
seem to correctly identify the NULL
value, but IS NULL
does not?