Link to home
Start Free TrialLog in
Avatar of batesit
batesitFlag for United States of America

asked on

How do I show employee and supervisor name using join?

I feel I'm so close, but am missing something obviously. I want to get the name of both the employee and supervisor where the name is stored in one table from a different database and the supervisor lookup table references the employee and supervisor id number.
Emp_M                                                           SupLookup
  SID                                                                    SID
  Emp_name                                                      SupID
                                                                            Status
                                                                            EmpJobNum

SID in SupLookup table references the employee, SupID in SupLookup references the supervisor. SID in Emp_M table references all employees (including supervisors).

This is what I have so far:
select b.SupID, b.status, b.EmpJobNum, a.EMP_NAME
from hpsa.[EMP].emp_m a
inner join TimeCardsV3.dbo.SupLookup b
on a.sid = b.SID

This gives me the name of the employee, but not the supervisor. If I call emp_name again, it just gives me the employee name again. I can't figure out how to connect the SupID to the SID without breaking the employee part. What am I missing?
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of batesit

ASKER

Excellent, thanks.