Get recursive parents with all leafs

gregoryred

New Member
my following Select Statement returns the output as attached image\[code\]Select * from CategoriesMap \[/code\]
EFVeB.png
How Can I pass the ID & get all of its ancestors, for example if I pass id=5 then Get rows like...\[code\]Internet Tv Jadoo Tv Jadoo Tv1 < -- id is 5 Shava Tv < -- This still falls under parent of Jadoo Tv Jalva Tv < -- This still falls under parent of Jadoo Tv\[/code\]& if I pass id=9 Then I get resultset of\[code\]Internet Tv Jadoo Tv Jadoo Tv Buy/Sell Buy Jadoo Tv < --- id is 9 Sell Jadoo Tv < -- this shares the same parent Jadoo Tv 1 < - child of Jadoo Tv Buy / Sell Jadoo Tv 2 Jadoo Tv 3 Shava Tv < --- childof Jadoo Tv Jalva Tv < --- child of Jadoo Tv\[/code\]I am open to a CTE or .NET solution.
 
Back
Top