Re: Nested Sets vs. Nested Intervals
From: -CELKO- <jcelko212_at_earthlink.net>
Date: 9 Nov 2005 17:19:10 -0800
Message-ID: <1131585550.727621.170830_at_f14g2000cwb.googlegroups.com>
Date: 9 Nov 2005 17:19:10 -0800
Message-ID: <1131585550.727621.170830_at_f14g2000cwb.googlegroups.com>
An employee and all their Supervisors, no matter how deep the organizational tree, with a column for sorting the path from root to a node:
SELECT O2.emp, (O2.rgt- O2.lft) AS path_order
FROM OrgChart AS O1, OrgChart AS O2
WHERE O1.lft BETWEEN O2.lft AND O2.rgt
AND O1.emp = _at_myemployee
ORDER BY path_order DESC;
Received on Thu Nov 10 2005 - 02:19:10 CET