Hi, I want to select the date and time of my employee whose date range 2014-01-05 to 2014-01-15 and time range to 6:00-9:00 from employee table
but my query fails
SELECT DateFrom,DateTo,(SELECT TimeIn,TimeOut FROM employe_table where TimeIn BETWEEN '6:00' and '9:00'
or TimeOut BETWEEN '6:00' and '9:00')
FROM employe_table WHERE
DateFrom BETWEEN '2014-01-05' and '2014-01-15' or DateTo
BETWEEN '2014-01-05' and '2014-01-15'
CREATE TABLE `employe_table` (
`EmpNo` int(11) NOT NULL AUTO_INCREMENT,
`DateFrom` date NOT NULL,
`DateTo` date NOT NULL,
`TimeIn` time NOT NULL,
`TimeOut` time NOT NULL,
PRIMARY KEY (`EmpNo`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=latin1
SELECT DateFrom
, DateTo
, TimeIn
, TimeOut
FROM employe_table
WHERE ( TimeIn BETWEEN '6:00' AND '9:00'
OR TimeOut BETWEEN '6:00' AND '9:00' )
AND ( DateFrom BETWEEN '2014-01-05' AND '2014-01-15'
OR DateTo BETWEEN '2014-01-05' AND '2014-01-15' )