I can of course do this in a server side language, but I wondered if it's possible to do within SQL.
I have a table like:
CREATE TABLE `dates` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`date_from` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`date_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
);
With some data like
+----+---------------------+---------------------+
| id | date_from | date_to |
+----+---------------------+---------------------+
| 1 | 2013-02-27 00:00:00 | 2013-03-01 00:00:00 |
| 2 | 2013-02-18 00:00:00 | 2013-02-20 00:00:00 |
+----+---------------------+---------------------+
(All the dates are at midnight)
I'd like to select these somehow to get back:
2013-02-27 00:00:00
2013-02-28 00:00:00
2013-03-01 00:00:00
2013-02-18 00:00:00
2013-02-19 00:00:00
2013-02-20 00:00:00
That is, all the dates in the ranges specified.
Any ideas?