Possible Duplicate:
Simplest way to do a recursive self-join in SQL Server?
I have to create a table in SQL that will comprise of groups of items/products. Each new group made will be made under one of the pre-defined groups or the groups previously formed. I want to keep all this data in a SQL Table. So far, I have though of creating a table like this:
- Group ID
- Group Name
- Group Under (This will store the ID of the group under which this group is from
But this can only refer to just the next level, how will I get to know who is the super-parent of this group.
For example:
- I have groups A, B, C.
- Ahas further subgroups- A1, A2, A3.
- A1has further subgroups,- A11, A12, A13.
I will I have the information about super-parent group i.e A from A11 or A22 or A33? 
Let me know if the problem is not clear..
 
     
    