I currently have a table containing a series of dates that staff are taking holidays:
DROP TABLE IF EXISTS `holidays`;
CREATE TABLE `holidays` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`staffid` int(11) DEFAULT NULL,
`startdate` datetime DEFAULT NULL,
`enddate` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `holidays` (`id`, `staffid`, `startdate`, `enddate`)
VALUES
(1,1,'2016-01-25 12:45:00','2016-01-29 12:30:00'),
(2,1,'2016-01-18 09:00:00','2016-01-18 12:45:00'),
(3,1,'2016-02-29 09:00:00','2016-03-04 16:30:00'),
(4,1,'2016-01-19 12:30:00','2016-01-19 15:00:00');
What I want to do is check whether any date in this working week (mon-fri) falls between any of the start and enddates in the table. This seems to be to require looping through each of the dates in this working week, but I do not know if this is possible in MySQL. I'd rather not loop through using PHP to send off multiple queries as that would probably end up being slow.
Any suggestions?