I am currently trying to optimize a database by combining queries. But I continue the dead end by optimizing the room availability request.
I have a room availability table, where in each record the number of rooms per day is indicated. It is formatted like this:
- room_availability_id (PK)
- room_availability_rid (fk_room_id)
- room_availability_date (2011-02-11)
- room_availability_number (number of rooms available)
The problem is getting a list of rooms that are available for EVERY given day. When I use IN () as follows:
WHERE room_availability_date IN('2011-02-13','2011-02-14','2011-02-15') AND room_availability_number > 0
If the 14th number has an availability of 0, it still gives me two more dates. But I only want this room_id when it is available for ALL three dates.
Please tell me that there is a way to do this in MySQL, except to request each combination of date / room / availability separately (here's what is being done now :-()
I tried all kinds of combinations, tried to use room_availability_date = ALL (...), tried some dirty duplicate subqueries, but to no avail.
Thank you in advance for any thoughts!
source share