Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    12

    Unanswered: SELF JOIN help needed

    Iíve got table Employees (EmpNo, Ename, Mgr)
    Where Mgr attribute is EmpNo of another Employee which means that if we have tuples
    1 |John |2
    2 |Mark| 7
    Means that Mark is Johnís manager.
    How can I obtain list of employees with ther managerís name as well as his number using only joins without any correlated(nested) subqueries?
    Thanx.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select e.EmpNo
         , e.Ename
         , m.EmpNo  as MgrNo
         , m.Ename  as MName
      from Employees as e
    inner
      join Employees as m
        on e.Mgr
         = m.EmpNo
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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