MySQL provides several MySQL-specific functions that test
relations between minimum bounding rectangles of two geometries
`g1`

and `g2`

. The return
values 1 and 0 indicate true and false, respectively.

Returns 1 or 0 to indicate whether the minimum bounding rectangle of

contains the minimum bounding rectangle of`g1`

. This tests the opposite relationship as`g2`

`MBRWithin()`

.mysql>

mysql>`SET @g1 = GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');`

mysql>`SET @g2 = GeomFromText('Point(1 1)');`

+----------------------+--------------------+ | MBRContains(@g1,@g2) | MBRWithin(@g2,@g1) | +----------------------+--------------------+ | 1 | 1 | +----------------------+--------------------+`SELECT MBRContains(@g1,@g2), MBRWithin(@g2,@g1);`

Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries

and`g1`

are disjoint (do not intersect).`g2`

Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries

and`g1`

are the same.`g2`

Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries

and`g1`

intersect.`g2`

Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries

and`g1`

overlap. The term`g2`

*spatially overlaps*is used if two geometries intersect and their intersection results in a geometry of the same dimension but not equal to either of the given geometries.Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries

and`g1`

touch. Two geometries`g2`

*spatially touch*if the interiors of the geometries do not intersect, but the boundary of one of the geometries intersects either the boundary or the interior of the other.Returns 1 or 0 to indicate whether the minimum bounding rectangle of

is within the minimum bounding rectangle of`g1`

. This tests the opposite relationship as`g2`

`MBRContains()`

.mysql>

mysql>`SET @g1 = GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');`

mysql>`SET @g2 = GeomFromText('Polygon((0 0,0 5,5 5,5 0,0 0))');`

+--------------------+--------------------+ | MBRWithin(@g1,@g2) | MBRWithin(@g2,@g1) | +--------------------+--------------------+ | 1 | 0 | +--------------------+--------------------+`SELECT MBRWithin(@g1,@g2), MBRWithin(@g2,@g1);`