Re: Nested Model
From: Joe Celko (joe.celko_at_northface.edu)
Date: 02/19/04
- Next message: Ben Amada: "Re: Int faster than Money?"
- Previous message: Tim: "Re: Sybase VS M$ SQL"
- In reply to: Robert Taylor: "Re: Nested Model"
- Next in thread: Robert Taylor: "Re: Nested Model"
- Reply: Robert Taylor: "Re: Nested Model"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Feb 2004 15:50:40 -0800
>> Nothing like a little shameless plug <<
Well, I cannot afford a banner spot on DevDex ...
>> When using the BETWEEN criteria for the nested model, we are not
querying for the UserID's the manager manages, but the node id of the
tree. <<
Actually, you are querying for the entire **subtree** that is rooted at
the node in the case of a known employee and all their Supervisors, no
matter how deep the tree.
SELECT O2.*
FROM OrgChart AS O1, OrgChart AS O2
WHERE O1.lft BETWEEN O2.lft AND O2.rgt
AND O1.emp = @myemployee;
The employee and all his subordinates as a nice symmetry to it.
SELECT O1.*
FROM OrgChart AS O1, OrgChart AS O2
WHERE O1.lft BETWEEN O2.lft AND O2.rgt
AND O2.emp = @myemployee;
After you get the positons in the Organizational Chart, you join it to
the Personnel table to find them.
--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
- Next message: Ben Amada: "Re: Int faster than Money?"
- Previous message: Tim: "Re: Sybase VS M$ SQL"
- In reply to: Robert Taylor: "Re: Nested Model"
- Next in thread: Robert Taylor: "Re: Nested Model"
- Reply: Robert Taylor: "Re: Nested Model"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|