Skip to main content

ST_WITHIN

Introduced or updated: v1.2.564

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

Syntax

ST_WITHIN(<geometry1>, <geometry2>)

Arguments

ArgumentsDescription
<geometry1>The argument must be an expression of type GEOMETRY.
<geometry2>The argument must be an expression of type GEOMETRY.
note
  • The function reports an error if the two input GEOMETRY objects have different SRIDs.

Return Type

Boolean.

Examples

SELECT ST_WITHIN(
TO_GEOMETRY('POINT(1 1)'),
TO_GEOMETRY('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))')
) AS within;

╭─────────╮
within
├─────────┤
true
╰─────────╯
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today