SQL大于,等于和小于 [英] SQL Greater than, Equal to AND Less Than
本文介绍了SQL大于,等于和小于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建如下查询,但是不确定如何正确编写代码, 我希望它在StartTime的1小时内返回所有预订,这是我想出的:
I want to create a query like the following, But im unsure of how to code it correctly, I want it to return all bookings within 1 hour of a StartTime, Here is what i came up with:
SELECT BookingId, StartTime
FROM Booking
WHERE StartTime <=> 1.00
可能吗?还是有办法解决?
Is the possible? or Is there a way round it?
在网络上找到的所有ive都并非要在同一查询中使用大于,等于和小于.
Everything ive found on the web hasn't been about using Greater than, Equal to and Less Than all in the same query.
推荐答案
假设您使用的是SQL Server:
Supposing you use sql server:
WHERE StartTime BETWEEN DATEADD(HOUR, -1, GetDate())
AND DATEADD(HOUR, 1, GetDate())
这篇关于SQL大于,等于和小于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文