MySQL mystery: Null value is not different from non-null string

前端 未结 5 651
伪装坚强ぢ
伪装坚强ぢ 2021-01-20 16:25

Why is this query returning 0 rows?

select t.f1, t.f2
from (select null f1, \'a\' f2 from dual) t
where t.f1<>t.f2;

This is a distill

5条回答
  •  梦毁少年i
    2021-01-20 16:54

    Try to do this query:

       select * from dual where NULL = NULL
    

    It returns 0 rows. That's because to compare a value with null you have to do IS NULL or IS NOT NULL, otherwise it will return false.

提交回复
热议问题