DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Simple query

  1. #1
    Join Date
    Dec 2000
    Location
    Virginia, USA
    Posts
    455
    Who do I write the query on emp table to find out name of the manager of each employee, Following is the basic emp table that oracle provide. Thanks in advance.

    EMPNO ENAME JOB MGR
    --------- ---------- --------- ----------
    7369 SMITH CLERK 7902
    7499 ALLEN SALESMAN 7698
    7521 WARD SALESMAN 7698
    7566 JONES MANAGER 7839
    7654 MARTIN SALESMAN 7698
    7698 BLAKE MANAGER 7839
    7782 CLARK MANAGER 7839
    7788 SCOTT ANALYST 7566
    7839 KING PRESIDENT
    7844 TURNER SALESMAN 7698
    7876 ADAMS CLERK 7788
    7900 JAMES CLERK 7698
    7902 FORD ANALYST 7566
    7934 MILLER CLERK 7782



  2. #2
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    select e.empno,e.ename,
    m.empno, m.ename
    from emp e, emp m
    where
    e.mgr = m.empno;

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    you use inner join for this purpose

    soemthing like

    Code:
    select a.ename boss, b.ename employee
    from emp a, emp b
    where a.empno=b.mgr
    /

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width