5. Geospatial Functions : Contains
 
Share this page                  
Contains
CONTAINS(g1 Geometry, g2 Geometry)
Alias: ST_CONTAINS
Returns 1 when g2 is inside g1; returns 0 otherwise.
Result type: integer
Examples:
SELECT CONTAINS(POLYFROMTEXT('POLYGON((0 0,0 10,5 5,10 10,10 0,0 0))'), POLYFROMTEXT('POLYGON((2 2,2 8,3 3,8 8,8 2,2 2))'));
-------------
col1
-------------
1
-------------
SELECT CONTAINS(POLYFROMTEXT('POLYGON((0 0,0 10,5 5,10 10,10 0,0 0))'), POLYFROMTEXT('POLYGON((2 2,2 8,7 7,8 8,8 2,2 2))'));
---------------
col1
---------------
0
---------------