SQL BETWEEN 逆序运算符条件值 [英] SQL BETWEEN Operator conditional value in Reverse Order

查看:39
本文介绍了SQL BETWEEN 逆序运算符条件值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么下面的 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 逆序运算符条件值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆