Tree view using SQL Query
I have a regions table of which I want a tree view (table simple ordered as tree) is it possible using sql queries help is appreciated, I tried to do it using self joins but i did not get the desired result. tree view is something like this Indiv Div1 Zon1 div2 zon2 div3 zon3 EDIT: as per Charles Bretana suggetion I tried CTE in below query and it did not give me desired result. WITH Emp_CTE (id, ParentID, name) AS ( SELECT id, ParentID, name FROM eQPortal_Region WHERE ParentID=0 UNION ALL SELECT e.id, e.ParentID, e.name FROM eQPortal_Region e INNER JOIN Emp_CTE ecte ON ecte.id = e.ParentID )