starfire
starfire

Reputation: 13

Table with multiple columns containing employee keys. How to link to employee master to get names?

My table has columns of data that contain employee keys for different departments. One column, for example would be business office, another admin.

I can't figure out how to write and sql that will join the employee master to return each persons name for each row. I could do it if it only had one column of employee master keys but it beat me

Upvotes: 0

Views: 148

Answers (1)

Rob Paller
Rob Paller

Reputation: 7786

I think from what you have described you need to join to the Employee Master table multiple times:

SELECT A.Col1
     , A.BOEmpID
     , BO.EmpName
     , A.AdminEmpID
     , AD.EmpName
     , <....>
FROM MyTable A
INNER JOIN Employees BO
        ON A.BOEmpID = BO.EmpID
INNER JOIN Employees AD
        ON A.AdminEmpID = AD.EmpID

Upvotes: 2

Related Questions