count total paired members of the tree by sqlquery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ashumeerut
    New Member
    • Oct 2013
    • 3

    count total paired members of the tree by sqlquery

    I am having a table tbltestingtree representing the tree structure, Member_Id is the id of the member, Parent_Id represent the Parentid of that member , Lefts and Rights tells us that the member is attached to the left or right of the Parent.
    **My problem is that i have to make a sqlquery that counts the total number of pared members for any particular parent ,**

    Ex- currently member with id 1 has 3 pairs with id 2,3 and 4
    currently member with id 2 has 1 pair with id 4

    Code:
          Member_Id     Parent_Id      Lefts         Rights
             1               Null       Null          Null  
             2                1          1            Null
             3                1         Null           1
             4                2          1            Null
             5                2         Null           1
             6                3          1            Null
             7                3         Null           1
             8                4          1            Null
             9                4         Null           1
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I don't understand why you're counting 4 in your results, its parent id is not 1.

    Comment

    • Ashumeerut
      New Member
      • Oct 2013
      • 3

      #3
      the answer is here :

      I am having a table tbltestingtree representing the tree structure, Member_Id is the id of the member, Parent_Id represent the Parentid of that member , Lefts and Rights tells us that the member is

      Comment

      Working...