1

Possible Duplicate:
SQL - detecting loops in parent child relations

I have a simple table with 2 columns id and parentid:

id    |   parentid
------------------
2         1
3         2
4         3
1         4

For example, in the above table, 1 is a child of 1 itself (1->2->3->4->1). How to detect such cases?

Would I require an extra column?

Community
  • 1
  • 1
mhn
  • 2,660
  • 5
  • 31
  • 51

0 Answers0