I have a table (prop_rate_info) where specific day wise property and availability information been stored. like:
+-----------+---------------+---------------+----------------+----------+
| id | property_id | check_in_date | available_room | price |
| (integer) | (integer) | (date) | (integer) | (double) |
+-----------+---------------+---------------+----------------+----------+
| 1 | 1 | 2018-07-20 | 2 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 2 | 1 | 2018-07-21 | 2 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 3 | 1 | 2018-07-23 | 2 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 4 | 2 | 2018-07-20 | 4 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 5 | 2 | 2018-07-21 | 1 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 6 | 2 | 2018-07-22 | 0 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 7 | 2 | 2018-07-23 | 4 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 8 | 3 | 2018-07-20 | 5 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 9 | 3 | 2018-07-21 | 5 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 10 | 3 | 2018-07-22 | 5 | 200 |
+-----------+---------------+---------------+----------------+----------+
| 11 | 3 | 2018-07-23 | 5 | 200 |
+-----------+---------------+---------------+----------------+----------+
I will give a date range and value for available room in integer. The query should search for each date of the range (from given range), if each day has available room value for a property, then it will give property id, otherwise it will ignore a property.
That means, if I give date range like 2018-07-20 to 2018-07-23 and available room value as 2, then it should check for each day (20th, 21st, 22nd, 23rd) whether it has available room of 2 for a property, if all day has that available room value, then it will give a property id.
This way it will give all property id.
I tried to use this query:
select property_id from prop_rate_info
where DATE(check_in_date) BETWEEN '2018-07-20' AND '2018-07-23'
and available_room >= 2
group by property_id;
This is giving all property id, though table dont have rocord for all property for each day for those given range.
From the sample data given above, this should give property_id as 3, as it has all day's record also it has the available_room is more >= 2 for each day.
Can you please help on this, how this query can be done?