MySQL检查日期范围是否在日期范围内
问题描述:
在为小型预订系统执行SQL查询时遇到麻烦,我有一个包含两个条目的表,其中包含两个不同的日期和一个数字.
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.
例如,如果我输入日期2015-01-02和2015-01-04,它将返回Nr 2和 2015-01-05和2015-01-08将返回Nr 1.
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.