作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何获得 4 到 8 之间的数字。我想要的答案是 5,6,7,但在 SQL Server 中使用时脚本返回 4,5,6,7,8:
SELECT *
FROM table
WHERE numbers BETWEEN '4' AND '8'
最佳答案
BETWEEN
包含在内。来自 MSDN:
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.
由于它是包容性的,因此您将需要使用大于和小于:
SELECT *
FROM yourtable
WHERE numbers > 4
AND numbers < 8
如果您想使用 BETWEEN
运算符,那么您需要缩短范围:
SELECT *
FROM yourtable
WHERE numbers between 5 AND 7
关于sql - SQL Server 中的 BETWEEN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12387587/
我是一名优秀的程序员,十分优秀!