sqlserver between

 sqlserver between

----如果UpdateTime为''或者为null,就用InsertTime条件查询
select * 
from WxUsers where BID='957' and ParentID='5537821'
and (COALESCE(UpdateTime,InsertTime) between '2016-06-06 17:49:13.755' and '2018-06-07 17:49:13.759' )

 

=====================================================

--UpdateTime='2018-06-06 17:49:13.760'
select * from  WxUsers where UserID='5537821'
and ( UpdateTime between '2018-06-06 17:49:13.755'and '2018-06-06 17:49:13.758' )
--结果没有数据

select * from  WxUsers where UserID='5537821'
and ( UpdateTime between '2018-06-06 17:49:13.755'and '2018-06-06 17:49:13.759' )
--结果有数据

select * from  WxUsers where UserID='5537821'
and ( UpdateTime between '2018-06-06 17:49:13.762'and '2018-06-06 17:49:13.765' )
--结果没有数据

select * from  WxUsers where UserID='5537821'
and ( UpdateTime between '2018-06-06 17:49:13.761'and '2018-06-06 17:49:13.765' )
--结果有数据

 

=====================================================

 

 

=====================================================

posted on 2022-10-28 18:09  Jankie1122  阅读(70)  评论(0编辑  收藏  举报