SELECT *
FROM DEPT D
WHERE EXISTS (SELECT *
FROM EMP E
WHERE E.DEPTNO = D.DEPTNO);
DEPTNO | DNAME | LOC
10 | ACCOUNTING | NEW YORK
30 | SALES | CHICAGO
20 | RESEARCH | DALLAS
SELECT *
FROM DEPT D
WHERE NOT EXISTS (SELECT *
FROM EMP E
WHERE E.DEPTNO = D.DEPTNO);
DEPTNO | DNAME | LOC
40 | OPERATIONS | BOSTON