Here's my database (free rooms in a hotel, simplified)
rooms_available:
id date_available room_id ================================ 1 2013-12-19 2 2 2013-12-20 2 3 2013-12-21 2 4 2013-12-22 2 5 2013-12-23 2 6 2013-12-25 3 rooms:
id name minimal_range ================================ 2 Apartment A 5 3 Apartment B 1 I want to query all rooms which are available between 2013-12-20 and 2013-12-22
My query is like:
select * from rooms_available where (date='2013-12-20' OR date='2013-12-21' OR date='2013-12-22') My questions:
- is there a more comfortable way? when the date range will be like 2 weeks, the query will also be very long (which will take much longer for querying)
- would it be possible to consider minimum ranges - for example: room_id 2 is only available for at least 5 nights (see table "rooms") -> so above query should return no records
Thanks