0

OK, so, here's the problem. I have three columns in MySQL table:

location_lat
location_lng
radius

I need to make a query that when user selects the point on map I get latitude,longitude values and to find all DB entries that contains this dot.

To illustrate it, I've made a mockup:

illustration

So, given the coordinates of the black marker I need to find only red circles and not the green ones.

Is it doable via MySQL?

I know how to make it in PHP, but that could be more resource intensive.

eboye
  • 318
  • 4
  • 10
  • 2
    Find the distance between your point and the latlong centres of all the circles. If the distance is less than the radius, your point is in the circle. To distance two LatLongs use the haversine formula. https://stackoverflow.com/questions/574691/mysql-great-circle-distance-haversine-formula Will help – Caius Jard Feb 08 '19 at 03:58
  • @CaiusJard thanks. That's exactly what I was looking for :) – eboye Feb 08 '19 at 04:18
  • Hmm, I've tested it now, and it seems that that solution is checking the distance that needs to be variable from the column. This answer is more like what I need. I just don't understand the syntax https://stackoverflow.com/a/29822023/2403126 – eboye Feb 08 '19 at 04:52

0 Answers0