这让我大吃一惊。
我想做的就是在长varchar
字段上进行基本的字符串比较。
我有一张大约的桌子。1200 万条记录。
如果我查询MY_FIELD='a string'
,我会得到 25947 的计数,这似乎是正确的。
如果我查询MY_FIELD!='a string'
,我得到的计数是 989。
这 2 个计数不应该等于 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';
NULL
不等于或不等于任何值,包括NULL
所以我希望d+e
等于c
和b+c
等于a
.