这让我大吃一惊.
我想做的就是在长varchar
场上进行基本的字符串比较.
我有一张大约一张桌子.12M记录.
如果我查询MY_FIELD='a string'
,我得到25947的计数,这似乎是正确的.
如果我查询MY_FIELD!='a string'
,我得到989的计数.
这两个计数不应该相加到12M的全表大小吗?
并MY_FIELD
设置了NULL
多少行?
a. select count(*) from mytable;
b. select count(*) from mytable where my_field is null;
c. select count(*) from mytable where my_field is not null;
d. select count(*) from mytable where my_field = 'some value';
e. select count(*) from mytable where my_field != 'some value';
Run Code Online (Sandbox Code Playgroud)
NULL
是不等于或不等于任何价值,包括NULL
所以我期望d+e
等同于c
和b+c
等于a
.