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

ST_DWITHIN



Returns TRUE if two GEOMETRY objects are within the specified Euclidean distance.

This function only supports GEOMETRY values.

Syntax

ST_DWITHIN(<geometry1>, <geometry2>, <distance>)

Arguments

ArgumentsDescription
<geometry1>The argument must be an expression of type GEOMETRY.
<geometry2>The argument must be an expression of type GEOMETRY.
<distance>The maximum Euclidean distance as a Float64-compatible value.

Return Type

Boolean.

Examples

SELECT ST_DWITHIN(TO_GEOMETRY('POINT(0 0)'), TO_GEOMETRY('POINT(1 1)'), 1.5); ╭───────────────────────────────────────────────────────────────────────╮ │ st_dwithin(to_geometry('POINT(0 0)'), to_geometry('POINT(1 1)'), 1.5) │ ├───────────────────────────────────────────────────────────────────────┤ │ true │ ╰───────────────────────────────────────────────────────────────────────╯
SELECT ST_DWITHIN(TO_GEOMETRY('POINT(0 0)'), TO_GEOMETRY('LINESTRING(2 0, 2 2)'), 1.9); ╭─────────────────────────────────────────────────────────────────────────────────╮ │ st_dwithin(to_geometry('POINT(0 0)'), to_geometry('LINESTRING(2 0, 2 2)'), 1.9) │ ├─────────────────────────────────────────────────────────────────────────────────┤ │ false │ ╰─────────────────────────────────────────────────────────────────────────────────╯

Was this page helpful?