Rooms Time Slot Availability

Posted on 2014-08-08
Last Modified: 2015-10-04
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?

Question by:Rahul Sehrawat
    LVL 32

    Accepted Solution

    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.
    LVL 107

    Expert Comment

    by:Ray Paseur
    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).

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now