The ST_INTERSECTS function tests whether two geographical objects intersect.
Syntax
BOOLEAN ST_INTERSECTS(GEOGRAPHY <value1>, GEOGRAPHY <value2>)Parameters
value1, value2: Required. Values of the GEOGRAPHY data type. You can construct GEOGRAPHY objects by using functions such as ST_GEOGPOINT, ST_GEOGFROMWKB, ST_GEOGFROMTEXT, ST_MAKELINE, and ST_MAKEPOLYGON.
Return value
Returns a BOOLEAN value. If the two geographical objects share at least one point, the function returns TRUE; otherwise, it returns FALSE.
Examples
-- Returns TRUE.
SELECT ST_INTERSECTS(ST_GEOGFROMTEXT('POINT(5 5)'), ST_GEOGFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'));
-- Returns FALSE because the polygon object contains a hole.
SELECT ST_INTERSECTS(ST_GEOGFROMTEXT('POINT(5 5)'), ST_GEOGFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (4 4, 6 4, 6 6, 4 6, 4 4))'));