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

前端 未结 5 656
伪装坚强ぢ
伪装坚强ぢ 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条回答
  •  不知归路
    2021-01-20 16:44

    SQL NULL does not work the way you would like it to work: http://en.wikipedia.org/wiki/Sql_null

    In short, NULL = NULL is not true. NULL <> NULL is not true. NULL <> 1 is not true. And so forth.

提交回复
热议问题