ST_Contains()¶
Returns
1when no part of the second geometry lies outside the first and its interior is contained.
Syntax¶
ST_Contains(geom1, geom2)
Aliases: none.
Arguments¶
geom1 and geom2 are GEOMETRY values.
Return Value¶
Returns BOOL.
Usage Notes¶
Both geometries must have the same SRID. Relationship predicates operate in the Cartesian plane (SRID 0); SRID 4326 geodetic predicates are not supported.
Examples¶
DROP DATABASE IF EXISTS geo_contains_demo;
CREATE DATABASE geo_contains_demo;
USE geo_contains_demo;
SELECT ST_Contains(ST_GeomFromText('POLYGON((0 0, 4 0, 4 4, 0 4, 0 0))'), ST_GeomFromText('POINT(2 2)')) AS contains_point;
DROP DATABASE geo_contains_demo;
See Also¶
ST_Within(), ST_Covers().