;WITH cte AS (
SELECT dbTable.*
FROM dbTable
WHERE id = 100000200
UNION ALL
SELECT dbTable.*
FROM dbTable
INNER JOIN cte ON cte.ParentID = dbTable.id
)
SELECT * FROM cte
--========Get all successor
;WITH cte AS (
SELECT dbTable.*
FROM dbTable
WHERE id = 100000200
UNION ALL
SELECT dbTable.*
FROM dbTable
INNER JOIN cte ON dbTable.ParentID = cte.id
)
SELECT * FROM cte
1 Comments
very nice......
ReplyDelete