Three tables Employee, Manager, User_Account
Employee contains Employee_ID and User_Account_ID, Manager contains Employee_ID and Manager_ID, User_Account contains User_Account_ID and Password,
Results: Employee_ID, Manager_ID, User_Account_ID(For Employee), Password (For Employee), User_Account_ID(For Manager), Password (For Manager)
Whats the best way to achieve the results above?
asked May 12 '10 at 05:48 AM in Default
SELECT E.Employee_ID, ME.Employee_ID AS Manager_ID, E.User_Account_ID AS Employee_User_Account_ID, (SELECT UA.Password FROM User_Account AS UA WHERE UA.User_Account_ID = E.User_Account_ID) AS Employee_Password, ME.User_Account_ID AS Manager_User_Account_ID, (SELECT UA.Password FROM User_Account AS UA WHERE UA.User_Account_ID = ME.User_Account_ID) AS Manager_Password FROM Manager AS M INNER JOIN Employee AS ME ON ME.Employee_ID = M.Manager_ID RIGHT OUTER JOIN Employee AS E ON E.Employee_ID = M.Employee_ID;
answered May 12 '10 at 08:49 PM