如何匹配DB2(z / OS)查询中的字符串?

时间:2010-11-03 13:56:20

标签: db2 mainframe zos

这让我大吃一惊。

我想要做的就是在varchar字段上进行基本的字符串比较。

我有一张大约一张桌子。 12M记录。

如果我查询MY_FIELD='a string',我的计数为25947,这似乎是正确的。

如果我查询MY_FIELD!='a string',我的计数为989。

这两个计数不应该加起来是12M的完整表格大小吗?

1 个答案:

答案 0 :(得分:6)

这些行中有多少行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和{{ 1}}等同于b+c