sql server BETWEEN and

1、用between and 查询时间

    SELECT * FROM dbo.CHECKINOUT  where USERID='17953' AND CHECKTIME BETWEEN'2013-03-16' AND '2013-03-21'

    数据库中明明有3月21的数据记录,但用BETWEEN and 这种写法就是没查出来

改成这种写法就可以查询出来

SELECT * FROM dbo.CHECKINOUT  where USERID='17953' AND CHECKTIME BETWEEN'2013-03-16' AND DATEADD(day,1,'2013-03-22')

2、两个sql语句结果不一样,第一条没有查询到结果,第二条才可以查询到结果,应该把小数字放在前面

SELECT *from t_PortGrant where StageID=73 AND PortPrice BETWEEN 270 AND 100
SELECT *from t_PortGrant where StageID=73 AND PortPrice BETWEEN 100 AND 270 

  

posted on 2016-03-02 18:01  梨窝★浅笑  阅读(1293)  评论(0编辑  收藏  举报

导航