Postgres NOT IN(null)没有结果 [英] Postgres NOT IN (null) gives no result
本文介绍了Postgres NOT IN(null)没有结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在对此查询使用Postgres
I'm using Postgres with this query
select
*
from Entity this_
where
(this_.ID not in (null))
为什么这样做我没有结果吗?我希望得到id不为空的所有行
Why does this give me no results? I would expect to get all rows where id is not null
with
(this_.ID not in (1))
我得到了预期的结果
推荐答案
(null)中的 [not]结果将始终为空。要与null进行比较,您需要
is [not] null
或 is [not]与null
select *
from Entity this_
where this_.ID is not null
如果要 where(ID不在(1,null)中)
可以做到
where ID is not null and ID not in (1)
这篇关于Postgres NOT IN(null)没有结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文