Within
WITHIN(g1 Geometry, g2 Geometry)
Alias: ST_WITHIN
Returns 1 if every point in g1 is in g2; returns 0 otherwise.
Result type: integer
Examples:
g2 is a point that is in the polygon g1 ;g1 also has points not in g2:
SELECT WITHIN(POLYFROMTEXT('POLYGON((2 2, 12 2, 12 12, 2 12, 2 2))'), POINTFROMTEXT('POINT(10 5)'));
-------------
col1
-------------
0
-------------
g1 and g2 share some points and have some points not in common:
SELECT WITHIN(LINEFROMTEXT('LINESTRING(10 5, 20 5)'), POLYFROMTEXT('POLYGON((2 2, 12 2, 12 12, 2 12, 2 2))'));
-------------
col1
-------------
0
-------------
Every point in g1 is also in g2; g2 has some points not in g1:
SELECT WITHIN(LINEFROMTEXT('LINESTRING(2 5, 8 5)'), POLYFROMTEXT('POLYGON((2 2, 12 2, 12 12, 2 12, 2 2))'));
-------------
col1
-------------
1
-------------
Last modified date: 01/30/2023