Having trouble making a SQL query for a small booking system, i have a table containing two entries which holds two different dates and a number.
Nr DateFrom DateTo
----------------------------
1 2015-01-01 2015-01-03
2 2015-01-05 2015-01-08
I want to query where i can enter two different dates and only return the number of the date range in the table that doesn't collide with the entered date range.
For example if i enter the dates 2015-01-02 and 2015-01-04 it would return Nr 2 and 2015-01-05 and 2015-01-08 would return Nr 1.
DEMO