I'm writing a query to list the first and last names of all staff who have ever taught any of the same course as Kim (Staff_Fname) Cox (Staff_Lname) or have ever taught in the same room (Loc_id) as Kim Cox.
So far I have written this (and it's full of errors):
SELECT KimClasses.Course_Code, KimClasses.Course_Name, St2.Staff_Fname, St2.Staff_Lname
FROM
(SELECT St.Staff_id, CS.C_SE_id, C.Course_code, C.Course_name
FROM Staff St
JOIN CourseSection CS ON St.Staff_id = CS.Staff_ID
JOIN Location L ON CS.Loc_ID = L.Loc_id
JOIN Course C ON CS.Course_ID = C.Course_ID
WHERE St.Staff_Fname = "Kim"
AND St.Staff_Lname = "Cox") KimClasses
JOIN CourseSection CS2 ON KimClasses.Course_ID = CS2.Course_ID
AND NOT KimClasses.Staff_id = St2.Staff_id;
But I'm not sure on how I would include the part to list the staff that have taught in the same room.
Database schema: http://i.stack.imgur.com/dTGV5.jpg