📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ST_CONTAINS



Returns TRUE if the second GEOMETRY object is completely inside the first GEOMETRY object.

Syntax

ST_CONTAINS(<geometry1>, <geometry2>)

Arguments

ArgumentsDescription
<geometry1>The argument must be an expression of type GEOMETRY object that is not a GeometryCollection.
<geometry2>The argument must be an expression of type GEOMETRY object that is not a GeometryCollection.

Return Type

Boolean.

Examples

SELECT ST_CONTAINS(TO_GEOMETRY('POLYGON((-2 0, 0 2, 2 0, -2 0))'), TO_GEOMETRY('POLYGON((-1 0, 0 1, 1 0, -1 0))')) AS contains ┌──────────┐ │ contains │ ├──────────┤ │ true │ └──────────┘ SELECT ST_CONTAINS(TO_GEOMETRY('POLYGON((-2 0, 0 2, 2 0, -2 0))'), TO_GEOMETRY('LINESTRING(-1 1, 0 2, 1 1)')) AS contains ┌──────────┐ │ contains │ ├──────────┤ │ false │ └──────────┘ SELECT ST_CONTAINS(TO_GEOMETRY('POLYGON((-2 0, 0 2, 2 0, -2 0))'), TO_GEOMETRY('LINESTRING(-2 0, 0 0, 0 1)')) AS contains ┌──────────┐ │ contains │ ├──────────┤ │ true │ └──────────┘

Was this page helpful?