Re: Nested set model with large gaps and spreads in the numbering

From: --CELKO-- <71062.1056_at_compuserve.com>
Date: 20 Sep 2002 08:20:00 -0700
Message-ID: <c0d87ec0.0209200720.5fa5d453_at_posting.google.com>


You put in a lot of work on this one! I also like the idea of giving the gaps names. One trick that might help is that the immediate subordinates (the children) can be found with this query:

SELECT B.emp AS boss, P.emp
  FROM OrgChart AS P

       LEFT OUTER JOIN
       OrgChart AS B
       ON B.lft
          = (SELECT MAX(lft)
               FROM OrgChart AS S
              WHERE P.lft > S.lft
                AND P.lft < S.rgt);
Received on Fri Sep 20 2002 - 17:20:00 CEST

Original text of this message