坚持修复这个查询,我写的两个命令中的错误

Stuck on fixing this query, mistakes in two commands that I wrote

EMPLOYEE (fname, minit, lname, ssn, birthdate, address, sex, salary, superssn, dno)
KEY: ssn

DEPARTMENT (dname, dnumber, mgrssn, mgrstartdate)
KEY: dnumber.

PROJECT (pname, pnumber, plocation, dnum)
KEY: pnumber.

WORKS_ON (essn, pno, hours)
KEY: (essn, pno)

DEPENDENT (essn, dependent-name, sex, bdate, relationship)
KEY: (essn, dependent-name)

所以我真的很困惑如何向 select 命令添加更多材料,比如说添加 SSN

我想查找项目编号 47 中所有经理的姓氏和名字:

SELECT lname, fname
FROM   employee e, department d
Where d.mgrssn  = e.ssn
WHERE  e.ssn IN (SELECT w.essn
                       FROM   works_on w, project p
                       WHERE  w.pno  = p.pnumber
                                AND     w.pno ='47'
                               );

但现在我想给它添加 ssn:

SELECT lname, fname, ssn
FROM   employee e, department d
Where d.mgrssn  = e.ssn
WHERE  ssn IN (SELECT w.essn
                       FROM   works_on w, project p
                       WHERE  w.pno  = p.pnumber
                                AND     w.pno ='02'
                               );

你能试试这个吗?

select * from employee e,works_on w,department d 
where e.ssn=d.mgrssn and e.ssn=w.essn and w.pno = 47

使用连接编辑

select * from employee 
join works_on on employee.ssn=works_on.essn 
join department on employee.ssn=department.mgsrssn
wher works_on.pno=47