I'm trying to create sql query for family tree purpuses that loops through table according to row values of the table it self.
So I have table that has values
person id | parent 1 | parent 2
1 | 2 | 5
2 | 3 | 4
3 | |
4 | |
5 | 6 | 7
6 | | 5
7 | |
and I want to select all the parets from the one I'm seaching to the oldest, after that search all of their offsping and after that their parents?
Examples