gpt4 book ai didi

postgresql - Postgres NOT IN (null) 没有结果

转载 作者:行者123 更新时间:2023-11-29 11:11:31 25 4
gpt4 key购买 nike

我在这个查询中使用 Postgres

select 
*
from Entity this_
where
(this_.ID not in (null))

为什么这没有给我任何结果?我希望得到所有 id 不为 null 的行

(this_.ID not in (1))

我得到了预期的结果

最佳答案

[not] in (null) 的结果将始终为 null。要与 null 进行比较,您需要 is [not] nullis [not] distinct from null

select *
from Entity this_
where this_.ID is not null

如果你想要 where (ID not in (1,null)) 你可以在你的评论中做

where ID is not null and ID not in (1)

关于postgresql - Postgres NOT IN (null) 没有结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17877100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com