Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Nested Sets Model of Hierarch... > 4.4. Functions in the Nested Sets Mo...

4.4. Functions in the Nested Sets Model

The level of a given node is a matter of counting how many (lft, rgt) groupings (superiors) this node's lft or rgt is within. You can get this by modifying the sense of the BETWEEN predicate in the query for subtrees:
SELECT :my_member, COUNT(Mgrs.member) AS lvl
FROM OrgChart AS Mgrs, OrgChart AS Workers
WHERE Workers.lft BETWEEN Mgrs.lft AND Mgrs.rgt

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint