SELECT distinct d.deptid, d.dept_name FROM rooms r LEFT JOIN departments d ON r.dept=d.deptid WHERE d.deptid != 1 OR d.dept != 3 OR d.dept !=42