I don't quite get how recursive queries work and how to solve this problem. We were given the table on the left and the structure looks like the tree on the right:
ID | Parent 1
1 null / \
2 1 2 3
3 1 \
4 3 4
5 4 / \
6 4 5 6
7 6 \
7
I know how to get all the parent nodes of every node... but I don't get how you find the max depth of the tree. Meaning I have to find out how many levels this tree has. We aren't given any more information
I would be super grateful if you could give me a solution for mysql, but any sql statement will help me figuring this out
Thanks in advance!