On 3/12/02 8:02 PM, "Atrix Wolfe" <[EMAIL PROTECTED]> wrote:

> it sounds like you should search for "joe celko's nested sets"

Bingo:

http://www.intelligententerprise.com/001020/celko1_1.shtml

> 1. Find an employee and all his/her supervisors, no matter how deep the tree.
> 
> 
> SELECT P2.*
>  FROM Personnel AS P1, Personnel AS P2
> WHERE P1.lft BETWEEN P2.lft AND P2.rgt
>   AND P1.emp = :myemployee;
> 
> 
> 2. Find the employee and all his/her subordinates. (This query has a nice
> symmetry with the first query.)
> 
> SELECT P1.*
>  FROM Personnel AS P1, Personnel AS P2
> WHERE P1.lft BETWEEN P2.lft AND P2.rgt
>   AND P2.emp = :myemployee;

Don't quite understand the theory, but all the code is there so I should be
able to muddle through :-)

Sheesh, why do I gotta start with the tricky questions first?

e.

________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to