with cte as ( select * from mytable where child = 100 union all select t.* from mytable t inner join cte on cte.parent = t.child ) select parent from cte
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)