Consider the set of relations for the given $SQL$ query:
EMP (eno, ename)
DEPT (dno,dname)
WORKS_IN (eno,dno)
Where primary keys of the relations are eno, dno in $EMP$ table and $DEPT$ table respectively and $\left ( eno,dno \right )$ of WORKS_IN are foreign keys referring to $EMP$$\left ( eno \right )$ and $DEPT$$\left ( dno \right )$
SELECT eno FROM WORKS_IN GROUP BY eno HAVING count (*) = (SELECT count(dno) FROM dept);
The above SQL query returns
- The eno’s of employees working in at least one department
- The eno’s of employees working in all departments
- The eno’s of employees working in 2 (or) more departments
- The eno’s of employees not working in any department