Quantcast
Channel: Active questions tagged cte - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 216

Getting Indirect parents

$
0
0

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


Viewing all articles
Browse latest Browse all 216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>