gpt4 book ai didi

sql - null 不在详尽列表中

转载 作者:行者123 更新时间:2023-12-02 06:40:01 24 4
gpt4 key购买 nike

我有一行全是 1、2、3 和 null。为什么没有两个返回相同的结果:

select * from foo where foobar not in (1, 2, 3);
select * from foo where foobar is not null;

第一个返回空集,而第二个像宣传的那样工作。现在我有点困惑 :-D 是否有某种“新手 SQL 中的 NULL”文档? :-D

(如果重要的话,我正在使用 Oracle)

最佳答案

这是因为你的第一条语句正在被这样评估:

select * from foo
where foobar <> 1 and foobar <> 2 and foobar <> 3

“null <> 1”的计算结果为 null,而不是 true/false,因此不返回任何内容。

关于sql - null 不在详尽列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9940827/

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