这是我的查询
SELECT S.sid,
S.sname,
M.major
FROM Student S,
Major M
WHERE NOT EXISTS(
(SELECT C.cno
FROM Courses C
WHERE S.sid = M.sid
AND M.dname = C.dname) EXCEPT
(SELECT E.cno
FROM Enroll E
WHERE S.sid = M.sid
AND S.sid = E.sid
AND M.dname=E.dname))
为什么我收到无效的SQL:ORA-00907:排队时错过右括号错误?
答案 0 :(得分:3)
EXCEPT
是一个SQLServer子句,在oracle MINUS
中用于相同的:
试试这个:
SELECT S.sid,
S.sname,
M.major
FROM Student S,
Major M
WHERE NOT EXISTS(
(SELECT C.cno FROM Courses C WHERE S.sid = M.sid AND M.dname = C.dname
)
MINUS
(SELECT E.cno
FROM Enroll E
WHERE S.sid = M.sid
AND s.sid = e.sid
and m.dname=e.dname
));