gpt4 book ai didi

SQL Server 2005 'between' 运算符(operator)行为 - bug 还是功能?

转载 作者:行者123 更新时间:2023-12-02 17:03:40 26 4
gpt4 key购买 nike

根据microsoft documentation ,“BETWEEN”运算符的行为应该是左侧和右侧都是闭区间,但是,以下代码:

SELECT CASE WHEN (1 BETWEEN 1 AND 2) THEN 'YEAH' ELSE 'NO' END AS [closed in the left],
CASE WHEN (1 BETWEEN 2 AND 1) THEN 'YEAH' ELSE 'NO' END AS [closed in the right]

否则显示。你能重现它吗?你觉得怎么样?

最佳答案

使用 BETWEEN 时,必须始终首先指定最小值。您引用的文档表明:

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.

所以你的第二个案例实际上正在测试:

1 >= 2 AND 1 <= 1

关于SQL Server 2005 'between' 运算符(operator)行为 - bug 还是功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6865270/

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