Display all the columns in Department for those that have rows in Employee or Project but not both.
- Department has column code.
- Employee has dcode (foreign key to Department).
- Project has dcode (foreign key to Department).
From what I can tell, there is no XOR in Access so I am not quite sure how to set it up. This is my attempt at it and it may not even be close as I am not very good at this.
Code:
SELECT *
FROM Department
WHERE EXISTS(SELECT * FROM Employee WHERE Department.code = Employee.dcode)
OR EXISTS(SELECT * FROM Project WHERE Department.code = Project.dcode)
AND NOT EXISTS(SELECT * FROM Project,Employee WHERE Department.code = Employee.dcode AND Project.dcode = Employee.dcode);
Can I even use OR EXISTS followed by AND EXISTS?