两个表
基本信息表a:pid(个人编号),,name(姓名),age(年龄),dept(部门),senior(上司)
支援认知信息表b:id(个人编号),job(职位),每个人允许多条记录要求:
1 查询年龄为30岁以上且任职数为两个以上的所有人员的基本信息
2 查询所有既有上司又有下属的职员的基本信息
基本信息表a:pid(个人编号),,name(姓名),age(年龄),dept(部门),senior(上司)
支援认知信息表b:id(个人编号),job(职位),每个人允许多条记录要求:
1 查询年龄为30岁以上且任职数为两个以上的所有人员的基本信息
2 查询所有既有上司又有下属的职员的基本信息
1: select * from a where age>30 and pid in(select id from b group by id having count(distinct job)>2)
2 select * from a where senior is not null
and exists(select 1 from a b where a.senior=a.pid)其中senior 是上司ID,與PID一樣.