0
我在创建SQL查询时遇到了一些问题。嵌套SQL查询 - 逻辑问题
在我的数据库中,我有两个表,房间和保留以及表的构成就像是:
表:房间
roomID : int (PK, auto increment, unique)
description : varchar
capacity : int
表:保留
resID : int (PK, auto increment, unique)
roomID : int (FK)
date : date
beginning : time
end : time
现在我想知道是否有可能创建一个查询,返回一个lis关于一些通过论证的房间。同一时间不应该有两个或更多的预订房间。
纯英文的查询会是这样的:
SELECT description from rooms
WHERE capacity is greater or equal to :passedCapacity
AND date not equal to :passedDate
OR date is equal to :passedDate BUT
:passedBeginning and :passedEnd do not collide with other reservations
我不知道该怎么做。
非常感谢任何形式的帮助。
预先感谢您!
你正在使用什么数据库,MySQL或SQL Server? –
我正在使用MySQL数据库。 – user3006108