After read a lot of posts about this. I need a good way to select events between two dates. The possible conditions are shown in the following figure:
My first attempt is the following:
SELECT *
FROM events
WHERE
(
start_date BETWEEN $start_select AND $end_select
OR
end_date BETWEEN $start_select AND $end_select
)
OR
(
start_date <= $start_select
AND
end_date >= $end_select
)
The problem is that it takes a long time to make the query.
Then I saw this post: Select data from date range between two dates where @dmlukichev talks about exclude all wrong options:
Something like this:
SELECT *
FROM events
WHERE NOT
(
start_date < $start_select
OR
end_date > $end_select
)
But it does not work me.
Any ideas?