tejasjoshi Posted April 22, 2009 Share Posted April 22, 2009 I have one table which has three fields. MId Name and ParentId. Suppose i have following table. MId Name ParentId 1 a 0 2 a1 1 3 a2 1 4 a3 1 5 a4 1 6 a11 2 7 a12 2 8 a13 2 9 a111 6 10 a112 6 11 a113 6 12 a1111 9 13 a1112 9 14 a1113 9 15 a1114 9 Above table shows the MId(memberid), membername and parent of member. I want to get all the child of particular member. Suppose i have Mid=2 then we can get all the childs and subchilds of MId 2. We can get result in following format. Parent Child a1 a11 a1 a12 a1 a13 a11 a111 a11 a112 a11 a113 a111 a1111 a111 a1112 a111 a1113 a111 a1114 I need solution of this question as soon as possible. please help me. Thanks in advance Quote Link to comment Share on other sites More sharing options...
fenway Posted April 22, 2009 Share Posted April 22, 2009 The adjacency list model (the one you are using) makes getting all parents or descendants a complex problem -- you'll have to self-JOIN as many times as you think the list is deep. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.