mysql不在查询中给出错误的结果

mrzz3bfm  于 2021-06-17  发布在  Mysql
关注(0)|答案(1)|浏览(264)
select count(*) from call_log
where relation_id in (14,15)
and date(from_unixtime(created_time/1000)) = '2018-12-10';

结果:1600

select count(*) from call_log
where relation_id in (14,15)
and date(from_unixtime(created_time/1000)) = '2018-12-10'
and id not in (NULL);

结果:0

select count(*) from call_log
where relation_id in (14,15)
and date(from_unixtime(created_time/1000)) = '2018-12-10'
and id in (NULL);

结果:0
理想情况下,查询2和查询3的结果之和应该等于查询1的结果。或者与null比较时出现问题。

aiazj4mn

aiazj4mn1#

IN() 无法处理 NULL 价值观。而是使用 IS ```
and id is not NULL

或者

and id is NULL

相关问题