你好,
我有一行数据,有一列,调用状态,里面的值为null。
如果我查询 select * from table where status not in ('EXP')
,在运行此查询之前,我认为我可以选择数据行,因为 status=null
,也请考虑 not in ('EXP')
。试了之后,发现查询不到这一行数据。想知道为什么会这样。
尝试用 Google 搜索,但也许我的问题不正确,所以我无法从 Google 获得正确的搜索结果。
请指教。
最佳答案
NULL 值仅使用 IS NULL
或 IS NOT NULL
进行检查
SELECT *
FROM table
WHERE status NOT IN ('EXP')
OR status IS NULL;
希望我已经理解你的问题。
也许反过来
SELECT *
FROM table
WHERE status NOT IN ('EXP')
AND status IS NOT NULL;
关于sql - db2 查询条件 where column not in () while the column value is null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27816596/