有没有人知道如何创建子查询来查找一位经理下的所有员工?例如,如果我想找一个在苏珊琼斯上工作的人,我该如何创建查询呢?
Manager Table:
Employee ID Manager_ID Name Title
1 NULL James Smith CEO
2 1 Ron Johnson Sales Manager
3 2 Fred Hobbs Sales Person
4 1 Susan Jones Support Manager
答案 0 :(得分:0)
select employeename,managerid
from manager
where manager_id is not null
group by employeename ,manager_id
答案 1 :(得分:0)
好吧,假设员工表简称为Employee,其密钥名为' Employee_ID' (就像在Manger表中一样),那么你只需要使用一个简单的Join:
SELECT e.* FROM Employee AS e JOIN Manger AS m ON e.Employee_ID=m.Employee_ID WHERE m.Name='Susan Jones'