作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
WHERE 子句可以返回 NULL 而不是 TRUE 或 FALSE 吗?
根据下面的练习,这是可能的,但我无法想象一个返回 NULL 的示例,这真的可能吗?
4. Which of the following values can NOT be returned after evaluation of WHERE clause
condition?
A. UNKNOWN
B. TRUE
C. FALSE
D. NULL
Answer: A. If the result of the condition in WHERE clause is not known, NULL is returned. In all
other scenarios, either TRUE or FALSE is returned.
最佳答案
在 SQL 中,所有逻辑运算符的计算结果为 TRUE、FALSE 和 UNKNOWN(Oracle docs),而 MySQL UNKNOWN 结果调用 NULL(MySQL docs)。
根据oracle文档:
"To test for nulls, use only the comparison conditions IS NULL and IS NOT NULL. If you use any other condition with nulls and the result depends on the value of the null, then the result is UNKNOWN."
"Can a WHERE clause return NULL instead of TRUE or FALSE?"
a.a >= all
) 评估为 UNKNOWN。
with table_a as (
select null as a from dual
union all
select 10 as a from dual
union all
select 5 as a from dual),
table_b as (
select null as a from dual
union all
select 10 as a from dual
union all
select 5 as a from dual)
select * from table_a a where a.a >= all(select a from table_b b)
关于sql - WHERE 子句谓词可以评估为 NULL 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34646831/
我是一名优秀的程序员,十分优秀!