I have following different tables
LeafChilds
ChildId, ChildName
1, Child1
2, Child2
Group
GroupId, GroupName
1, Group1
2, Group2
3, All
GroupChildMapping
GroupId, ChildId
1, 1
2, 1
2, 2
GroupGroupMapping
GroupId, ParentGroupId
1, 3
1, 3
I am looking for query to find indirect parents for LeafChilds.In above example - child1 is in Group1 and Group1 has parent group as ALL. So indirectly child1 is in ALL group as well.
OUTPUT
Child1, Group1
Child1, ALL