I wasn't criticizing your approach at all. Nine years ago I wasn't
even aware there was something called SQL, let alone building
applications with it. And it's only been in the past couple years
that I discovered nested sets.
As to your question about depth, here's the answer:
SELECT t.id, t.name, (
SELECT COUNT(*)
FROM myTable t2
WHERE left <= t.left
AND right >= t.right
) AS depth
FROM myTable t
WHERE .... something or other ...
As before, change the <= and >= to < and > to get the ancestor count
rather than depth.
cheers,
barneyb
On 2/1/06, Peter Bell <[EMAIL PROTECTED]> wrote:
> Hi Barney,
>
> Agree wholeheartedly with performance comments re: my approach. Never said
> it was good - I just didn't know about nested sets in '97!!! Am looking to
> port to a nested set model based on your comments.
>
> Do you know any easy way to get the nest level for each record using a
> nested set without additional queries? For example, a fully extended sidebar
> navigation pulling from a nested set page table with a different style for
> each indent level . . .
>
> Best Wishes,
> Peter
>
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/
Got Gmail? I have 100 invites.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231045
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54