vendredi 26 décembre 2014

MYSQL query to find records between two date range


I am working in a web application using PHP and MySQL.


I have two tables




  1. Employee


    | employee_id | sup_id | email_id | Password |




  2. Coaching


    | coaching_id | emp_id | coaching_start_date | coaching-end_date |




I want a query to find out the employees who are not enrolled for any coaching program between a specified date range such as Start Date "2015-01-22" and End Date "2015-03-12".


Now I am using query like this,


SELECT employee_id FROM employee WHERE sup_id = 3 AND employee_id NOT IN (SELECT emp_id FROM (coaching) WHERE (start_date NOT BETWEEN "2014-12-26" AND "2015-01-30") AND (end_date NOT BETWEEN "2014-12-26" AND "2015-01-30"))


Where is the issue in my query


Thanks





Aucun commentaire:

Enregistrer un commentaire