SQL SERVER BETWEEN + ID 精确到ID和某一时间的范围
{
灵感来自https://www.cnblogs.com/starts/p/5235962.html
--查询出ID是10086的整数类型并且时间在2020年11月24日到2020年11月25日
SELECT * FROM tableName
where ID=10086 AND TIME BETWEEN '2020-11-24' AND '2020-11-25'
}
{
//https://www.cnblogs.com/starts/p/5235962.html
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
}