具有多个返回值的INTERSECTing表

时间:2013-11-03 15:20:28

标签: sql oracle

请问如何检查此SQL问题的类似结果组。

===========
EMPLOYEE
===========
ID | Name |
===========
 1 | EMP1 |
 2 | EMP2 |

==================
HASSKILL
==================
EMPID | SkillID  |
  1   | 001      |
  1   | 002      |
  1   | 003      |
  2   | 003      |
  2   | 004      |
  2   | 005      |

JOB
===================
JobID | NEEDSKILL |
===================
  1   | 002       |
  1   | 003       |

我可以使用以下命令获得作业所需的技能:

SELECT NEEDSKILL FROM JOB WHERE JobID = 1;

如何在没有pl / sql的情况下“循环”通过员工并显示具有作业1所需技能的员工?

1 个答案:

答案 0 :(得分:2)

select empid from HASSKILL, JOB
where jobid = 1 and skillid = needskill
group by empid
having count(0) = (select count(0) from JOB where jobid = 1)