Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8013761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:43:13+00:00 2026-06-04T19:43:13+00:00

I am building a mobile webapp with jquery mobile. Now let me first sketch

  • 0

I am building a mobile webapp with jquery mobile. Now let me first sketch the thing I am doing.

A user want to reserve a meeting-room. First he chooses a room and only that room he wants to reserve, no other one. Than he also enters a begin and end DATETIME. This is the period he wants to have this room.

Now, I have a function in my webservice which gives a list back with all the reservations that are made on that specific meeting-room. Later on I am going to check in my javascript if this list is empty or not.

Now my Database structure.

I have table Reservations with the following design

 ID           --> int
  ROOMID       --> int
  DATE_BEGIN   --> DATETIME
  DATE_END     --> DATETIME

I have also a table ROOM with the following design

   ID            --> int
   NAME          --> VARCHAR(30)

Now an insert of a row in the table reservation looks like this

     ID            --> 1
     ROOMID        --> 2
     DATE_BEGIN    --> 2012-01-01 12:02:33
     DATE_END      --> 2012-01-01 14:00:00

For now I have this query

SELECT res.DATE_BEGIN,res.DATE_END 
FROM reservations res
INNER JOIN room roo
ON res.ROOMID =roo.ID
WHERE WHERE res.DATE_BEGIN <> @DATE_BEGIN
AND res_DATE_END <> @DATE_END

Now my question is what query should it be to get the right result. Also the reservations that are in the past shoud be filtered out.

Could anybody help ?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:43:14+00:00Added an answer on June 4, 2026 at 7:43 pm

    You need to check if one date range overlaps another date range.

    New Date Range =               |-----------|
    Test1          =      |=====|
    Test2          =            |=====|
    Test3          =                  |=====|
    Test4          =                        |=====|
    Test5          =                              |=====|
    Test6          =            |=================|
    

    Only Test1 and Test5 do not overlap.

    Colisions can therefore be found with…

    SELECT
      res.DATE_BEGIN, res.DATE_END
    FROM
      reservations res
    INNER JOIN
      room roo
        ON res.ROOMID =roo.ID
    WHERE
          res.DATE_BEGIN < @DATE_END
      AND res_DATE_END   > @DATE_BEGIN
    

    Note:

    Take care with boundary conditions. If one meeting ends and 10am and another starts at 10am, this wouldn’t normally be considered an overlap. Which is why I use < and >.

    EDIT

    For reasons out of the scope of this question and answer, such a query as I highlighted above is not easily optimised using indexes.

    For this reason, an alternative approach is to create blocks of time for which the room can be booked. No-one needs to start a meeting at 2 minutes and 33 seconds past mid-day. Instead they’d start it at 12:00. As such blocks of 5 minutes are normally accurate enough, and indeed systems often use 15 minute blocks or even 30 minute blocks.

    This means one booking can take multiple records (1 record per block of time booked), but every query on that data become simpler to resolve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a mobile webapp with jquery mobile. Now what I want 2
I am building a mobile webapp with jquery mobile. Now what I have. I
I am building a webapp with jquery mobile. I want to do a basic
I am building a webapp with jquery mobile where I need to get data
I am building a webapp using jQuery Mobile and AJAX to pull out SQL
I am building a mobile version of my company website, and one thing we
I am building a mobile app using Jquery mobile. It´s a multi-page app all
I'm currently building a Python webapp on the Google App Engine and I want
I am in the process of building an mobile/web application. I want to use
I'm building a mobile interface with JQuery Mobile for an already existing web app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.