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 8859217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:00:09+00:00 2026-06-14T15:00:09+00:00

I have a working reservation query. This query checks which items are available for

  • 0

I have a working reservation query. This query checks which items are available for the time of reservation.

[PROJECT]: projectid, datefrom, dateto, …
[ITEM]: itemid, itemgroupid, …
[ITEMGROUP]: itemgroupid, itemgroupname, …
[RESERVELIST]: itemid, projectid, reservelistnr

SELECT *
FROM item i inner join itemgroup ig on i.itemgroupid = ig.itemgroupid
WHERE i.itemid NOT IN  (
                        SELECT r.itemid 
                        FROM reservelist r inner join project p on r.projectid = p.projectid
                        WHERE p.datefrom BETWEEN '$datefrom' AND '$dateto'
                        OR p.dateto BETWEEN '$datefrom' AND '$dateto'
                        OR '$datefrom' BETWEEN p.datefrom AND p.dateto
                        OR '$dateto' BETWEEN p.datefrom AND p.dateto
                        )
ORDER BY itemid 

$datefrom and $dateto are the dates of the time of reservation.
Now this query works well, but if someone make a reservation between 08:00 – 21:00, the next reservation can only be done at 21:01 and not at 21:00 sharp. So I need to have a smaller than and greater than.

I played alot with the < and >, but somehow it doesn’t seem to work.

My best guess is that this should be the good solution:

SELECT *
FROM item i inner join itemgroup ig on i.itemgroupid = ig.itemgroupid
WHERE i.itemid NOT IN  (
                        SELECT r.itemid 
                        FROM reservelist r inner join project p on r.projectid = p.projectid
                        WHERE p.datefrom > '$datefrom' AND p.datefrom < '$dateto'
                        OR p.dateto > '$datefrom' AND p.dateto < '$dateto'
                        OR '$datefrom' > p.datefrom AND '$datefrom' < p.dateto
                        OR '$dateto' > p.datefrom AND '$dateto' < p.dateto
                        )
ORDER BY itemid 

Unfortunately, it isn’t.


Anyone any idea?

  • 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-14T15:00:10+00:00Added an answer on June 14, 2026 at 3:00 pm
    WHERE i.itemid NOT IN  (
                            SELECT r.itemid 
                            FROM reservelist r inner join project p on r.projectid = p.projectid
                            WHERE p.datefrom BETWEEN '$datefrom' AND '$dateto'
                            OR p.dateto BETWEEN '$datefrom' AND '$dateto'
                            OR '$datefrom' BETWEEN p.datefrom AND p.dateto
                            OR '$dateto' BETWEEN p.datefrom AND p.dateto
                            )
    

    Works.

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

Sidebar

Related Questions

I'm working with a domain model, in which I have a Reservation class: class
Iam working on small booking room system. In my solution I have a Reservation
I have working with a project and i added a share button to product
I have working website in PHP with a MySQL backend which has several tables
I have a third party library which I finally have working within my MonoTouch
Have been working on this question for a couple hours and have come close
I have working on an application which captures screen shots and create video from
I have working code: [self performSelector:@selector(doSomething) ]; but when I change this line to:
i have working codes from my server which is really working using Xampp server
I have been working on a project for a month or so now to

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.