SELECT Surname
FROM Worker
WHERE NOT EXISTS
(
SELECT *
FROM Project, Works_at
WHERE NOT EXISTS
(
SELECT *
FROM Works_at
WHERE Works_at.WorkerId =Worker.Id
AND Works_at.PNum = Project.PNumber
)
);
或者
SELECT Surname
FROM Worker
WHERE NOT EXISTS (
SELECT *
FROM Works_at
WHERE Id = WorkerId
);
当我运行查询时,它说“SELECT”附近有语法错误会出现什么问题?第一个选择所有项目中的工人作品。第二个选择工人不在任何项目中工作。提前致谢
表是
工人 = {Name, Surname, Id, Salary, DptNum}
部门 = {DptName, DptNumber}
Works_at = {WorkerId,PNum,小时}
Project={PName, PNumber, DptNum} 和
Works_at(WorkerId) → Worker(Id)
Works_at(Pnum) → Projekt(PNumber)
项目(DptNum) → 部门(DptNumber)
工人(DptNum) → 部门(DptNumber)