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

From: --CELKO-- <>
Date: 20 Sep 2002 08:20:00 -0700
Message-ID: <>

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

       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