0

I have a table

Id      |   Name    | ParentId
1       | Parent    | 0
2       | Subparent | 1
3       | Child     | 2

What query to retrieve one of its parent name (if any) and its parent sub (child) name whenever I input the ID, so for example

input ID = 1,
ouput = Parent | Subparent | Child

Input ID = 2,
Output = Parent | Subparent | Child

Input ID = 3,
Output = Subparent | Child

0 Answers0