我有一个名为 platform 的表,其中有一列名为 entityid。 entityid 中的数据应该遵循 n.n.n 格式(其中 n = 1 个或多个数字,第一个数字是站点 ID)。
如果我运行这个查询:
SELECT count(*) FROM platform
我得到:16063所以我的表中有 16063 行。当我尝试仅过滤站点 18 时,我运行此查询:
SELECT count(*) FROM platform
where entityid like '18.%.%'
我得到:4454到目前为止,一切都很好。但是如果我试图找到不在站点 18 的平台:
SELECT count(*) FROM platform
where entityid not like '18.%.%'
我得到:11608问题来了:4454 + 11608 = 16062
我缺少记录。我想我得到了站点 18 的所有平台,然后是站点 18 以外的所有平台 - 我怎么会遗漏一条记录?
问题可能是空值。试试这个,看看它是否返回一条记录:
select *
from platform
where entityid is null;
NULL 值几乎使所有比较都失败(is null
除外)。
Tôi là một lập trình viên xuất sắc, rất giỏi!