You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
GROUP BY t.`T_teacher_ID`
ORDER BY `T_lastname` ASC' at line 11
Query:
SELECT *
FROM `teacher` t
LEFT JOIN `college` c ON c.`T_teacher_ID` = t.`T_teacher_ID`
LEFT JOIN `lesson` l ON l.`T_teacher_ID` = t.`T_teacher_ID`
WHERE
`T_published` = 1 AND
(
c.`C_end_datetime` < NOW() OR
l.`L_start_datetime` < NOW()
) AND
t.`T_teacher_ID` NOT IN ()
GROUP BY t.`T_teacher_ID`
ORDER BY `T_lastname` ASC