I have a table structure like so
Id Desc Node
---------------------
1 A
2 Aa 1
3 Ab 1
4 B
5 Bb 4
6 Bb1 5
these Desc
values are presented in a listview to the user, if the user chooses Bb
, I want the ID 5
and also the ID 4
becuase thats the root node of that entry, simular to that if the user chooses Bb1
, I need ID 6
, 5
and 4
I am only able to query one level up, but there could be n
levels, so my query at the moment looks like this
SELECT Id
FROM tbl
WHERE Desc = 'Bb1'
OR Id = (SELECT Node FROM tbl WHERE Desc = 'Bb1');