我在My SQL Workbench中有代码行,但是我收到错误:错误代码:1242。子查询返回超过1行。
SELECT Fname, Lname, Dnum, Pno
FROM EMPLOYEE e, PROJECT p, WORKS_ON w
WHERE p.Dnum = (SELECT Dno FROM EMPLOYEE WHERE e.Ssn = w.Essn AND w.Pno = p.Pnumber)
我正在尝试显示正在处理未由其部门赞助的项目的员工表。
答案 0 :(得分:1)
试试这个
do(onNext:)
使用SELECT Fname, Lname, Dnum, Pno
FROM EMPLOYEE e, PROJECT p, WORKS_ON w
WHERE p.Dnum in (SELECT Dno FROM EMPLOYEE WHERE e.Ssn = w.Essn AND w.Pno =
p.Pnumber);
子句instad in
答案 1 :(得分:0)
优化查询:
SELECT Fname, Lname, Dnum, Pno
FROM EMPLOYEE e
INNER JOIN WORKS_ON w ON e.Ssn = w.Essn
INNER JOIN PROJECT p ON w.Pno = p.Pnumber AND p.Dnum = e.Dno