If you want to include NULL
values as "not equal" then you need a NULL
safe operator. Otherwise, the <>
returns NULL
, which is treated as "false" in a WHERE
clause.
You haven't specified your database, but standard SQL provides one:
where Drive_Status is distinct from 'Success'
If Drive_Status
is NULL
, then this returns TRUE
rather than NULL
.
Not all databases support this. Some use <=>
as NULL
-safe equality (that is NULL <=> NULL
evaluates to true). In these, you can use:
where not Drive_Status <=> 'Success'
And in others, you need to be more specific:
where Drive_Status <> 'Success' or Drive_Status is null
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…