Working Query: My query is working and I am also getting the result I desired. I just want to know if I am doing anything wrong because I heard it is not the right way to use IF inside Where Clause but in my case, it is even in a subquery. I have made this query myself. Let me know if there is a better alternative for my query.
Looking for: I am trying to get all those employees who are not busy between 14:00 & 15:00 where 14:00 and 15:00 is a time coming from input fields(like a search).
SELECT *
FROM `schedule`
WHERE appointment_id NOT IN (
SELECT appointment_id
FROM `schedule`
WHERE ( IF(start_time < '14:00', '14:00', start_time) >= '14:00'
AND IF(end_time > '15:00', '15:00', end_time) >= '14:00')
AND (IF(start_time < '14:00', '14:00', start_time) <= '15:00'
AND IF(end_time > '15:00', '15:00', end_time) <= '15:00')
AND `appoint_date` = '2018-11-30')