I have a mysql table with some date ranges, for example:
start: 2015-09-10 end: 2015-09-10
Now, I have to check if another date range is inside the start-end date, even if only for some days.
- 2015-09-02 -> 2015-09-03 is outside the range;
- 2015-09-05 -> 2015-09-11 is inside the range;
- 2015-09-11 -> 2015-09-12 is inside the range;
- ...
I have these query, it works for case 1 and 2:
SELECT * FROM prenotazione WHERE id_stanza=1 AND (start BETWEEN '2015-09-11' AND '2015-09-12' and end BETWEEN '2015-09-11' AND '2015-09-12' )
For the case 3, the query returns no result, even id the given date are inside the range. Can you help me?