Re: Box query
From: Mikito Harakiri <mikharakiri_nospaum_at_yahoo.com>
Date: 21 Apr 2006 18:58:51 -0700
Message-ID: <1145671131.059290.281130_at_i40g2000cwc.googlegroups.com>
Date: 21 Apr 2006 18:58:51 -0700
Message-ID: <1145671131.059290.281130_at_i40g2000cwc.googlegroups.com>
Bob Badour wrote:
> Mikito Harakiri wrote:
>
> > Mikito Harakiri wrote:
> >
> >>Given a set of n-dimensional boxes
> >>find all the pairs that intersect...
> >
> > table boxes (
> > *id* integer,
> > dimension# integer,
> > low integer,
> > high integer
> > )
> >
>
> select b1.id as box1, b2.id as box2
> from boxes b1, boxes b2
> where b1.id < b2.id
> and not exists (
> select 1 from boxes b3, boxes b4
> where b3.id = b1.id
> and b4.id = b2.id
> and b4.dimension# = b3.dimension#
> and (b4.high < b3.low or b4.low > b3.high)
> )
> group by 1, 2
> ;