MySQL Forums
Forum List  »  General

Re: Modified Preorder Tree Traversal - Advanced question
Posted by: Roland Bouman
Date: August 24, 2005 06:01AM

Ok, sorry 'bout that bittie bugsy. This should work fine:

select r.name
, d.name
, d.lft
, d.rgt
, d.zoom
from regions r
inner join regions d
on r.lft <= d.lft
and r.rgt >= d.rgt
where r.name = 'UK'
and d.zoom <= 5
and not exists (
select null
from regions z
where r.lft <= z.lft
and r.rgt >= z.rgt
and z.lft < d.lft
and z.rgt > d.rgt
and z.zoom <= 5
and z.zoom >= d.zoom
)

Of course, the subquery must be bound to the 'root' instance of the regions table in exactly the same way as the 'descendants' instance.

Don't hesitate the double check the results. I would be honoured if the google maps users could benefit from this, so post right ahead.

good luck!

Options: ReplyQuote


Subject
Written By
Posted
Re: Modified Preorder Tree Traversal - Advanced question
August 24, 2005 06:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.