I'm trying to create a stored procedure in MySQL to check if a given POINT is inside a POLYGON but I get the error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 7
This is my query:
CREATE PROCEDURE IsInsidePolygon(
IN polygon_coordinates VARCHAR(200),
IN point_coordinates VARCHAR(200)
)
BEGIN
DECLARE
polygonData GEOMETRYCOLLECTION;
DECLARE
pointData POINT;
SET
polygonData = ST_GEOMFROMTEXT(
CONCAT('POLYGON((', polygon_coordinates, '))')
);
SET
pointData = ST_GEOFROMTEXT(
CONCAT('POINT(', point_coordinates, ')')
);
SELECT
post_id
FROM
wp_postmeta
WHERE
ST_CONTAINS(polygonData, pointData);
END;
I'm a beginner in SQL so I can't tell what I'm doing wrong here. Thanks in advance!