I have a scenario where my data is visually shown in a tree structure like below.
i.e.
- Parent Node
- Child Node 1
- Child Node 1.1
- item
- Child Node 1.1
- Child Node 1
In the database, the item record only stores the NodeId of Child Node 1.1. So basically, the item has an indirect relationship with the Parent Node and Child Node 1.
How can I query the tables to return all the records with direct and indirect relationships?
i.e.
ItemId Name NodeId
1 Item1 1
1 Item1 2
1 Item1 3