Need help on my query please

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' 	



Thank you in advance

Can you please post the output of SHOW CREATE TABLE employe_table ?

Hi SpacePhoenix!


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' )

Thanks r937

Hi r937,

Can i ask help again? what if i have empno ‘10200’ .how do i apply this to your query?

Thank you in advance

append an AND condition to the WHERE clause

Thank you r937 it helps me :slight_smile: