5 and have the following scenario:
I have a database table with two columns: id(int)
, parentId(int)
.
Lets say my data looks like this
id parentId
1 null
2 1
3 1
4 3
5 3
6 4
7 4
8 6
Now I would like to write a query which list all elements which have a specific element as ancestor. How can this be done?
For example I want all elements that have 4 as ancestor; 6,7,8
.