3336
MariaDBERRORNotableSpatial / GISHIGH confidence
Cannot perform spatial operation on geometries with different SRIDs
Production Risk
Low — query fails; no data is modified.
How to reproduce
trigger — this will error
trigger — this will error
SELECT ST_Distance(ST_GeomFromText('POINT(0 0)', 4326), ST_GeomFromText('POINT(0 0)', 3857));expected output
ERROR 3336 (HY000): Binary geometry function ST_Distance given two geometries of different SRIDs.
Fix
Use ST_Transform
Use ST_Transform
SELECT ST_Distance(ST_Transform(g1, 4326), g2) FROM geom_table;
Why this works
ST_Transform reprojects geometry to the target SRS before comparison.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3336 ER_TRANSFORM_DIFFERENT_SRIDS
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev