Hello,
I don't know how to solve this problem purely with SQL or a stored procedure.
There is a table called tlb_Users looking like this:
[tt]
UserID SuperiorID
1 1
2 1
3 2
4 3
[/tt]
What I need is quite simple:
I want to know all the inferiors of one User (and himself).
e.g. the UserID is "2" the output should be "2", "3", "4" (4 because his superior is 3 who is inferior of 2).
Simpler example is UserID 3, where only "4" and "3" is the output.
Problem is that there could be more and more "nested" IDs
by adding new users with superiors which are inferiors of another superior and so on.
Is there a posibility to do this by SQL or do I need a stored procedure for this task ?
Or is there even a simpler possibility to solve this problem ?
Thanks in advance,
Jens
I don't know how to solve this problem purely with SQL or a stored procedure.
There is a table called tlb_Users looking like this:
[tt]
UserID SuperiorID
1 1
2 1
3 2
4 3
[/tt]
What I need is quite simple:
I want to know all the inferiors of one User (and himself).
e.g. the UserID is "2" the output should be "2", "3", "4" (4 because his superior is 3 who is inferior of 2).
Simpler example is UserID 3, where only "4" and "3" is the output.
Problem is that there could be more and more "nested" IDs
by adding new users with superiors which are inferiors of another superior and so on.
Is there a posibility to do this by SQL or do I need a stored procedure for this task ?
Or is there even a simpler possibility to solve this problem ?
Thanks in advance,
Jens