[GIS] MySql select points contained in polygon

mysql-spatial

I am extremely new to mysql, but I cannot find the error in this query

SELECT latitude, longitude from mytable where ST_CONTAINS(ST_GEOMFROMTEXT('POLYGON((47 -67, 47 -123, 21 -78, 47 -67)'), point(longitude, latitude))

The polygon is a triangle that covers most of the US. All of the lat/lng of the points should be inside the above polygon wkt, yet I get no rows. I have reversed the wkt coords in case I had it backwards, but still no luck. I am hoping I have an obvious mistake.

Best Answer

You are missing a closing parentheses at the end:

SELECT latitude, longitude from mytable where ST_CONTAINS(ST_GEOMFROMTEXT('POLYGON((47 -67, 47 -123, 21 -78, 47 -67)'), point(longitude, latitude)))

Related Question