Re: Modified Preorder Tree Traversal - Advanced question
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!