georgesOne
Technical User
Hi All:
I finally figured out that I can get a Supervisor / Employee relationship through a self join like:
SELECT tblStaff.EmployeeID, tblStaff.Manager, tblStaff.[Last Name] & ", " & tblStaff.[First Name] AS Employee
FROM tblStaff INNER JOIN tblStaff AS Supervisors ON tblStaff.Manager = Supervisors.EmployeeID
ORDER BY Supervisors.[Last Name] desc, tblStaff.[Last Name];
Which gives me
ID Manager Employee
3 Vinet, M. Garcia, Mike
7 Vinet, M. Mendes, Joe
12 Vinet, M. Myers, Klaus
27 Myers, K. Antonio, Bernadette
29 Myers, K. Gonzales, Frederic
Obviously, Myers, K(laus) is a manager managed by Vinet, M.
How can I get the result:
ID Level1 Level2 Level3 Level4.......
3 Vinet, M. Garcia, M.
7 Vinet, M. Mendes, J.
12 Vinet, M. Myers, K. Antonio, B.
12 Vinet, M. Myers, K. Gonzales, F.
and so on, similar what you get in a treeview.
What I want is that each Level can have access to all the lower level records, e.g. Vinet should be able to see Antonio, B.'s record.
Any suggestion is welcome.
Georges.
I finally figured out that I can get a Supervisor / Employee relationship through a self join like:
SELECT tblStaff.EmployeeID, tblStaff.Manager, tblStaff.[Last Name] & ", " & tblStaff.[First Name] AS Employee
FROM tblStaff INNER JOIN tblStaff AS Supervisors ON tblStaff.Manager = Supervisors.EmployeeID
ORDER BY Supervisors.[Last Name] desc, tblStaff.[Last Name];
Which gives me
ID Manager Employee
3 Vinet, M. Garcia, Mike
7 Vinet, M. Mendes, Joe
12 Vinet, M. Myers, Klaus
27 Myers, K. Antonio, Bernadette
29 Myers, K. Gonzales, Frederic
Obviously, Myers, K(laus) is a manager managed by Vinet, M.
How can I get the result:
ID Level1 Level2 Level3 Level4.......
3 Vinet, M. Garcia, M.
7 Vinet, M. Mendes, J.
12 Vinet, M. Myers, K. Antonio, B.
12 Vinet, M. Myers, K. Gonzales, F.
and so on, similar what you get in a treeview.
What I want is that each Level can have access to all the lower level records, e.g. Vinet should be able to see Antonio, B.'s record.
Any suggestion is welcome.
Georges.