0

i want to Select ID from table Locations where a point ( 25.10785 55.18114 ) exists in a polygon that.

I tried everything possible , while it returns null for everything.

Polygon((25.11031 55.18408,25.11109 55.18459,25.11288 55.18811,25.11653 55.19301,25.12197 55.20176, 25.1034 55.23103, 25.09471 55.24247, 25.0826 55.24944, 25.05652 55.24897, 25.05526 55.23672, 25.05306 55.22412, 25.06665 55.22071, 25.07212 55.21617, 25.07821 55.20957, 25.09016 55.19002, 25.09583 55.18403, 25.1046 55.17734, 25.10785 55.18114,25.11031 55.18408))

this is how the polygon looks like.

I want mysql to return ID if a point exists in the polygon

  • 1
    We are always glad to help and support new coders but you need to help yourself first. :-) [After doing more research](https://meta.stackoverflow.com/q/261592/1011527) if you have a problem post what you've tried with a clear explanation of what isn't working and provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Read [How to Ask](http://stackoverflow.com/help/how-to-ask) a good question. Be sure to [take the tour](http://stackoverflow.com/tour) and read [this](https://meta.stackoverflow.com/q/347937/1011527). – Dave Jun 17 '18 at 10:19
  • Possible duplicate of [Mysql select where polygon contains point always false](https://stackoverflow.com/questions/16659897/mysql-select-where-polygon-contains-point-always-false) – Progman Jun 17 '18 at 13:57

1 Answers1

0

Have a look at the mysql functions Containt or ST_Contains. ST_Contains(g1, g2) returns 1 or 0 to indicate whether g1 completely contains g2.

In your example you could do something like:

SELECT id FROM your_table WHERE CONTAINS(your_polygon, PointFromText(POINT(25.10785 55.18114))

Make sure to check what mysql version you are using.

Sebastian
  • 11
  • 1