Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2010
    Posts
    4

    Unanswered: query related to employee table

    plz help me with the query


    to get manager name corresponding to employee names in predefined employee table in oracle.



    as in the employee table we have manager ids corresponding to employee names so wat subquery do i use

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    We won't do your homework, but if you show us what you have tried we can help steer you to the correct solution.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Quote Originally Posted by beilstwh View Post
    We won't do your homework, but if you show us what you have tried we can help steer you to the correct solution.
    This is wat i have tried


    SELECT ENAME,MGR FROM EMPLOYEE;

    BUT THE ABOVE QUERY GIVES MANAGER IDS 4 CORRESPONDING ENAMES..HOW TO GET THE ENAMES WHO ARE MANAGERS TO SOME OTHERS EMPLOYEE.

    anyways thanks for the response

  4. #4
    Join Date
    Mar 2010
    Posts
    4
    I tried the following query also

    select ename as "mgr name" from employee where empno in(select mgr from employee);

    but the above just gives all manager names..i want to find our manager name corresponding to an employee

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Does the assignment say this has to be done with a subquery?

  6. #6
    Join Date
    Mar 2010
    Posts
    4
    Quote Originally Posted by MCrowley View Post
    Does the assignment say this has to be done with a subquery?

    No it doesnt say...can it be solved without subquery

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by icy_cool View Post
    ...can it be solved without subquery
    yes, with a self-join

    why are you shocked?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    The following is an example of a self join

    select b.name
    from emp a, emp b
    where a.mgr_empno = b.emp_no
    group by b.name;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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