Bhupendra Singh

Bhupendra Singh

  • NA
  • 225
  • 148.7k

How to select parent ids

Jun 10 2013 4:57 AM

I have table with such structure.

ElementId |  ParentId
-------------------
1         | NULL
2         | 1
3         | 2
4         | 3

Let say current element has Id 4. I want to select all parent ids. Result should be: 3, 2, 1


Answers (3)