Webbo_1980
asked on
How do i do an inner/ recurrsive join on a single table?
How do I join a table on its self i.e. lets say for example that I have a table with the following schema i.e.
Table 1, with columns ID, Name, ParentId and lets say ParentId was a forgeign key for a matching row in the same table, how would I get all rows returned with all rows containing parented in order so e.g.
1, aaa, null
2, bbb,1
3,ccc,2
4,ddd,null
5,eee,4
And lets say i made a query which said i want all rows with an id of 1 and all child rows from 1 whether there child or child of child,or child of child of child and so on, .
So e.g. lets say i wanted all row related to id of . So in this instance i'd get the following returned in this order i.e.
1, aaa, null ---> Parent
2, bbb,1 ----> Child
3,ccc,2 ----> Child of child with parent od 1
Thanks
Webbo
Table 1, with columns ID, Name, ParentId and lets say ParentId was a forgeign key for a matching row in the same table, how would I get all rows returned with all rows containing parented in order so e.g.
1, aaa, null
2, bbb,1
3,ccc,2
4,ddd,null
5,eee,4
And lets say i made a query which said i want all rows with an id of 1 and all child rows from 1 whether there child or child of child,or child of child of child and so on, .
So e.g. lets say i wanted all row related to id of . So in this instance i'd get the following returned in this order i.e.
1, aaa, null ---> Parent
2, bbb,1 ----> Child
3,ccc,2 ----> Child of child with parent od 1
Thanks
Webbo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.vbforums.com/showthread.php?t=366078
This article contains same information that you need