So, I have a table with start, end, taxiand driver. The city now wants to get a historical look at the month that had a cabin for a month, and when any changes occurred.
Thus, it captures assignment lines that started in July 2014, ended in July 2014, or continued (started before July and ended after a month or have not finished yet).
My question is: is there a more efficient or elegant query to get these strings?
SELECT * FROM `taxi_assignments` WHERE
(`start` BETWEEN '2014-07-01 00:00:00' AND '2014-07-31 23:59:59')
OR (`end` BETWEEN '2014-07-01 00:00:00' AND '2014-07-31 23:59:59')
OR (`start` < '2014-07-01 00:00:00' AND
(`end` > '2014-07-31 23:59:59' OR `end` = '0000-00-00 00:00:00')
)
source
share