ENAME JOB DNAME MGR EMPNO
---------- --------- -------------- ---------- ----------
CLARK MANAGER ACCOUNTING 7839 7782
KING PRESIDENT ACCOUNTING 7839
MILLER CLERK ACCOUNTING 7782 7934
JONES MANAGER RESEARCH 7839 7566
FORD ANALYST RESEARCH 7566 7902
ADAMS CLERK RESEARCH 7788 7876
SMITH CLERK RESEARCH 7902 7369
SCOTT ANALYST RESEARCH 7566 7788
WARD SALESMAN SALES 7698 7521
TURNER SALESMAN SALES 7698 7844
ALLEN SALESMAN SALES 7698 7499
JAMES CLERK SALES 7698 7900
BLAKE MANAGER SALES 7839 7698
MARTIN SALESMAN SALES 7698 7654
从上表中我想知道来自智者的empname和他们的经理名字。
我有两个表,一个是emp表,另一个表是dept通过执行以下查询我带来了上面的结果。
SQL> select ename, job, dname, mgr, empno
from emp e, dept d
where d.deptno = e.deptno;
答案 0 :(得分:0)
SQL> select e.ename emp_name, e.empno, e.job, m.ename mng_name,m.empno mng_empno
, dname from emp e, emp m, dept d where e.deptno = d.deptno and m.empno(+) = e.m
gr;