• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 59
  • Last Modified:

Rooms Time Slot Availability

Hi Experts,
I am working on a web project where I have different kinds of meeting rooms (room1, room 2, room 3) and more can be added by the admin. Each room have different quantity as well.

So my table structure is
Table: Room

Table: Booking:
fromtime (Datetime format)
totime (datetime format)

I want to check the availability of rooms according to time depending on the user input.  how can I do that?

Rahul Sehrawat
Rahul Sehrawat
1 Solution
Daniel WilsonCommented:
Find all rooms available (not booked) between Sept 1 and Sept 3:
Select R.* from
Room R Left Join
(Select R2.room_id from Room R2 Inner Join Booking B on R2.room_id = B.room_id
Where fromtime <= '2014-09-03' and totime >= '2014-09-01') Booked on R.room_id = Booked.room_id
Where Booked.room_id is NULL

Open in new window

Obviously, the dates in your query replace the literals in mine.
Ray PaseurCommented:
This is called a "resource scheduling" calendar.  Please see Practical Application #12 in this article (you may want to read the entire article to know what you're getting into before you try to use the Application #12 code).

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now