Self JOIN
The output should be lie this from an EMPLOYEE table
Employee Emp# Manager Mgr#
BLAKE 7698 KING 7839
CLARK 7782 KING 7839
JONES 7566 KING 7839
MARTIN 7654 BLAKE 7698
ALLEN 7499 BLAKE 7698
TURNER 7844 BLAKE 7698
JAMES 7900 BLAKE 7698
WARD 7521 BLAKE 7698
FORD 7902 JONES 7566
SMITH 7369 FORD 7902
SCOTT 7788 JONES 7566
ADAMS 7876 SCOTT 7788
MILLER 7934 CLARK 7782
TRY SELF JOIN, with two alias of same table, considering then as separate two tables
SELECT e.ename, e.empno, m.ename as manager, e.mgr FROM emp e, emp m WHERE e.mgr = m.empno
Comments
Post a Comment