ST_WITHIN
functionsupportedCore SQL functionsReturns true if the first geospatial object is fully contained by the second geospatial object. In other words: - The first GEOGRAPHY object g1 is fully contained by the second GEOGRAPHY object g2. - The first GEOMETRY object g1 is fully contained by the second GEOMETRY object g2. Calling ST_WITHIN(g1, g2) is equivalent to calling ST_CONTAINS(g2, g1). Although ST_COVEREDBY and ST_WITHIN might seem similar, the two functions have subtle differences. For details on the differences between “covered by” and “within”, see the Dimensionally Extended 9-Intersection Model (DE-9IM). Note This function does not support using a GeometryCollection or FeatureCollection as input values. Tip You can use the search optimization service to improve the performance of queries that call this function. For details, see Search optimization service.
Syntax
ST_WITHIN( <geography_expression_1> , <geography_expression_2> )
ST_WITHIN( <geometry_expression_1> , <geometry_expression_2> )
Parameters
| Name | Required | Description |
|---|---|---|
geography_expression_1 | required | A GEOGRAPHY object that is not a GeometryCollection or FeatureCollection. |
geography_expression_2 | required | A GEOGRAPHY object that is not a GeometryCollection or FeatureCollection. |
geometry_expression_1 | required | A GEOMETRY object that is not a GeometryCollection or FeatureCollection. |
geometry_expression_2 | required | A GEOMETRY object that is not a GeometryCollection or FeatureCollection. |
Returns
BOOLEAN.