I have a table in database
EmployeeID TeamLeadID
2 1
3 2
4 3
5 NULL
1 NULL
6 1
7 2
8 3
Now what I want is to retrieve all the TeamLeadsID (i.e all the upper hierarchy) for a given EmployeeID
-
For
EmployeeID = 2I should get ans 1 (because we don't haveTeamleadIDforEmployeeId = 1) -
For
EmployeeID = 4I should get 3,2 and 1 (because 4->Teamlead is 3, 3 -> Teamlead is 2, 2 -> TeamLead is 1) -
Likewise for
EmployeeID = 7I should get 2 and 1 only
while for 5 & 1 it should be Null as clearly seen from the table itself
Aucun commentaire:
Enregistrer un commentaire