Query
SELECT employee.emp_number as employee_id,
employee.termination_id,
employee.firstname as user_name,
termination.termination_date
FROM employee
JOIN user ON user.emp_number = employee.emp_number
JOIN reportto ON reportto.emp_number = employee.emp_number
LEFT JOIN termination ON
( termination.id = employee.termination_id
AND termination.termination_date > '2016-01-01')
WHERE ohrm_user.created_by = '31'
GROUP BY employee.emp_number
What I am trying
In the employee table by default termination_id is set NULL. If employee is terminated then the id from termination table is set as value. I want to get all employees who are not at all terminated or terminated before a certain date.
The above query gets all results including results with termination_date less than 2016-01-01. Is it possible to modify the query so that it omits the results with termination_date less than 2016-01-01? or do I have to execute 2 different queries and combine the result to achieve this.
Note to avoid confusion: I want employees who are still working (not terminated) AND not terminated before 2016-01-01