Hello Guys,
This is my first post. I am a newbie to Access and I am having difficulty with a query I am trying to do.
I have a one-to-many relational hotel database set up with 5 tables:
Bookings
Customers
Employees
Rooms
Room Types
What I am trying to do is to run a query where I can check to see when a room is vacant. For the date range I am using a parameter Start Date and End Date.
I think I might be close to this but the problem I am having is that when I run the query every single room shows as vacant when I know that these rooms are definitely not vacant.
Here is the SQL code I am working with at the moment:
PARAMETERS [Start Date] DateTime, [End Date] DateTime;
SELECT R.*
FROM ROOMS AS R LEFT JOIN BOOKINGS AS B ON R.RoomNo = B.RoomNo
WHERE (((B.RoomNo) Is Null)) OR ((([End Date])<.[ArrivDate])) OR ((([Start Date])>(.[ArrivDate]+.[DurStay])));
I would greatly appreciate it if you guys could cast your eye over this to see where I am going wrong. I have spent many, many hours on this and can't seem to figure it out for myself.
Greatly appreciated,
shauneyd
This is my first post. I am a newbie to Access and I am having difficulty with a query I am trying to do.
I have a one-to-many relational hotel database set up with 5 tables:
Bookings
Customers
Employees
Rooms
Room Types
What I am trying to do is to run a query where I can check to see when a room is vacant. For the date range I am using a parameter Start Date and End Date.
I think I might be close to this but the problem I am having is that when I run the query every single room shows as vacant when I know that these rooms are definitely not vacant.
Here is the SQL code I am working with at the moment:
PARAMETERS [Start Date] DateTime, [End Date] DateTime;
SELECT R.*
FROM ROOMS AS R LEFT JOIN BOOKINGS AS B ON R.RoomNo = B.RoomNo
WHERE (((B.RoomNo) Is Null)) OR ((([End Date])<.[ArrivDate])) OR ((([Start Date])>(.[ArrivDate]+.[DurStay])));
I would greatly appreciate it if you guys could cast your eye over this to see where I am going wrong. I have spent many, many hours on this and can't seem to figure it out for myself.
Greatly appreciated,
shauneyd
Last edited: