[英]MySQL NOT IN query giving wrong results
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比較時存在一些問題。
IN()
無法處理NULL
值。 改為使用IS
and id is not NULL
要么
and id is NULL
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.