Php mysql检查其他日期范围中的日期范围
我有一个日期范围的行Php mysql检查其他日期范围中的日期范围,php,mysql,date,range,Php,Mysql,Date,Range,我有一个日期范围的行 title | fromDate | tillDate ------------------------------------ my event | 2014-03-12 | 2014-03-13 my event 2 | 2014-03-14 | 2014-03-17 my event 3 | 2014-03-01 | 2014-03-10 my event 4 | 2014-03-01 | 2014-03-09 现在我有了第二对日期范围,我想检查事件是否在日期
title | fromDate | tillDate
------------------------------------
my event | 2014-03-12 | 2014-03-13
my event 2 | 2014-03-14 | 2014-03-17
my event 3 | 2014-03-01 | 2014-03-10
my event 4 | 2014-03-01 | 2014-03-09
现在我有了第二对日期范围,我想检查事件是否在日期范围内。。比如说
检查开始日期=2014-03-10
checkEndStartDate=2014-03-14
因此,范围将是“我的事件”、“我的事件2”和“我的事件3”
此时此刻,我只想尝试获取我的范围内的所有日期(2014-03-10和2014-03-14之间),并为其编写一个大查询。。。但一定有更简单的方法来做到这一点吗?试试这个:
select title from table
where checkStartDate <= fromDate
and checkEndStartDate <= tillDate
从表中选择标题
其中checkStartDate从表中选择标题,其中(日期('2014-03-10')介于日期(fromDate)和日期(tillDate)之间,或日期(fromDate)和日期(tillDate)之间,或(日期('2014-03-10')=日期(tillDate)))
使用此代码
select * from events_table where fromDate >= checkStartDate and tillDate <= checkEndStartDate
select*from events\u table其中fromDate>=checkStartDate和tillDate可能重复
select * from events_table where fromDate >= checkStartDate and tillDate <= checkEndStartDate