【发布时间】:2018-11-30 16:25:54
【问题描述】:
select * from table_Sample
where ID = 9229
and Datetime between '2018-06-18T18:30:00.00'
AND '2018-06-19T18:29:59.59'
第二个选项:
select * from table_Sample
where ID = 9229
and Datetime >= '2018-06-18T18:30:00.00'
AND Datetime <= '2018-06-19T18:29:59.59'
您能否解释一下两个查询在性能或结果集或其他方面有什么区别?
【问题讨论】:
-
你都试过了吗?
-
是的,我得到了相同的结果集
-
如果你在你的服务器上试一试,你也许会有答案
-
所以没有性能差异吧?
-
我更喜欢
>= dt1 AND <= dt2,因为您可以直接看到它的含义以及它的包容性,而BETWEEN隐藏了这个事实。您也可以轻松地将其更改为(例如)>= somedate AND < someother。 What do BETWEEN and the devil have in common?
标签: sql-server