Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on a query. 1

Status
Not open for further replies.
Oct 11, 2007
2
US
I have a 2 tables one that holds employee information and another that holds product information. The product information holds 2 fields (manager,salesman)which reference a unique key on the employee table. My query needs to return product information with both manager and salesman. I have an inner join from manager field to the employee PK and returns the field employee name. I dont know how to do the same for the salesman field. I can add another inner join from salesman field to the employee PK but cannot return the field employee name because its being taken by the manager request. If anyone can point me in the right direction or atleast let me know what such query is called so I can research it better.
 
You must use 2 instances of the employee table with different aliases:
SELECT P.*, M.name, S.name
FROM tblProduct P
INNER JOIN tblEmployee M ON P.managerID = M.employeeID
INNER JOIN tblEmployee S ON P.salesmanID = S.employeeID

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top