I just can't find a solution to my problem:
I have a table employees with id's name and the id they report to.
Employees:
id name reports_to
2 name2 55
3 name3 2
4 name4 3
5 name5 3
6 name6 2
7 name7 33
8 name8 55
now I need to be able to select the person that reports to id 55, and all the person that report to this person (id2). But just one level down.
the result would look like this:
2 name2 55
3 name3 2
6 name6 2
8 name8 55
I tried joins and subquery but without success.
Edit: If possible the result should be ordered in a way my result table looks: - person that reports to id 55 (i.e. #2) - person that report to #2 should follow immediately