how to count number of left node and right node in an mlm tree

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jitenrajput49
    New Member
    • Oct 2013
    • 5

    how to count number of left node and right node in an mlm tree

    Hello Friends,

    I've a table as given below

    Code:
    ID LChild RChild
    1      2              3
    2     4               6
    3     5               7
    4    8               9
    5    10          11
    6   12          13
    7    0           14

    Now i've to find out the LChild of 1, 1 has 2 in it's left 3 in it's right and 2 has 4,6 as it's child and 4 and 6 has also two-two child each......At final 1 has 7 child on it's left and on it's Right it's 6

    i want to Count Left and right node and level for MLM application

    And also i've find out for each ID i.e 1,2,3,4,5,6,7
    Last edited by Rabbit; Oct 28 '13, 03:58 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Since the tree is numbered incorrectly for a SQL only solution, you will need to use a cursor to implement a recursion.

    Comment

    • jitenrajput49
      New Member
      • Oct 2013
      • 5

      #3
      how,
      please tell me how we use cursor for recursion and give the code if you have please it's very urgent for me



      thanks in advance

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Sorry but this isn't a code writing service. Please make an attempt and post back with your code if you run into trouble and provide the error messages that you get.

        Comment

        Working...