问题描述
为什么下面的 SQL 查询会显示结果?
Why the following SQL query show results?
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
但是当我们改变值的顺序时,它不会显示任何结果?
but when we change the order of value it will not show any result?
SELECT * FROM Products
WHERE Price BETWEEN 20 AND 10;
推荐答案
如果 test_expression 的值大于或等于 begin_expression 的值且小于或等于 end_expression 的值,则 BETWEEN 返回 TRUE.如果 test_expression 的值小于 begin_expression 的值或大于 end_expression 的值,则 NOT BETWEEN 返回 TRUE.
BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression. NOT BETWEEN returns TRUE if the value of test_expression is less than the value of begin_expression or greater than the value of end_expression.
在您的情况下,您的语句评估为大于等于20且小于等于10
In your case, your statement evaluates to
greater than or equal to 20 AND less than or equal to 10
这篇关于SQL BETWEEN 逆序运算符条件值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!