在 SQL 中,BETWEEN 语句是否必须采用 BETWEEN 最低和最高的形式?
例如,如果我这样做:
SELECT * FROM Users WHERE UserId BETWEEN 100 AND 1
结果会是什么?
编辑:抱歉,你是对的,我应该指定。 我不想知道将返回的确切行数,我只是想知道它是否会返回 1 到 100 之间的行,或者是否会从 min(UserId)
返回行1 和 100 到 max(UserId)
。
For example, if I did:
SELECT * FROM Users WHERE UserId BETWEEN 100 AND 1
what would the results be?
Edit: Sorry, you're right, I should have specified. I didn't want to know the exact number of rows that would return, I just wanted to know if it would return rows that were between 1 and 100 or if it would return rows from min(UserId)
to 1 and 100 to max(UserId)
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是
So BETWEEN 100 and 1 的简写,不会匹配任何内容。
is shorthand for
So BETWEEN 100 and 1 won't match anything.
这可能取决于您的 RDBMS,但为什么不尝试一下呢? 在 MySQL 上,我从 BETWEEN 100 AND 1 查询中没有得到任何行,而我却从请求 BETWEEN 1 到 100 中得到行。
This probably depends on your RDBMS, but why not just try it out? On MySQL, I get no rows from a BETWEEN 100 AND 1 query whereas I do get rows from asking for BETWEEN 1 and 100.