Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005
    Posts
    50

    Arrow Unanswered: joe celko nested set model: how to compute the lft and rgt cols

    Hi,

    With reference to http://www.intelligententerprise.com...questid=235427
    I want the "sql stmt" which wud give the lft and rgt col values..

    i am reading his book but cant understand where he explains
    wat lft and rgt cols are..

    "The root is always (lft,rgt) (1, 2*(Select count(*)from table) and leaft nodes are (lft+1=rgt)"

  2. #2
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by dbaguru
    Hi,

    With reference to http://www.intelligententerprise.com...questid=235427
    I want the "sql stmt" which wud give the lft and rgt col values..

    i am reading his book but cant understand where he explains
    wat lft and rgt cols are..

    "The root is always (lft,rgt) (1, 2*(Select count(*)from table) and leaft nodes are (lft+1=rgt)"
    My suggestion would be to go through the book again.

    Look at the NestTree
    node lft rgt
    'A' 1 12
    'B' 2 3
    'C' 4 11
    'D' 5 6
    'E' 7 8
    'F' 9 10


    It says : the root is always (lft,rgt)=(1,2 * (SELECT COUNT(*) FROM TreeTable)) and leaf nodes always have (lft+1)=rgt)

    Select node AS root
    FROM NestTree
    WHERE lft=1

    i.e root is according to the above 'A' 1 ,12

    and leaf node is

    SELECT node AS leaf
    FROM NestTree
    WHERE lft=(rgt-1)

    i.e 'B' 2,3
    I hope u got it now...
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  3. #3
    Join Date
    Jun 2005
    Posts
    50
    i understood the relationship between lft and rght cols..
    but how on earth do we get the values for those cols in the 1st place...

  4. #4
    Join Date
    Jun 2005
    Posts
    50
    dont bother i figured it out...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •