3

Possible Duplicate:
SQL: Determine if one coordinate is in radius of another

In a table I have stored latitude and longitude (as floats). Now I want to query my table to find all rows which have coordinates within a given radius (which can ben 2km, 5km, 10km etc. etc.). I really don't have a clue how to achieve this so any help will be greatly appreciated. I'm not sure how query, because I think the result will be an endless set of coordinates representing the 'border' of the radius where I somehow have to tell my table to search for results within that 'border'.

Community
  • 1
  • 1
Ben Fransen
  • 10,884
  • 18
  • 76
  • 129

1 Answers1

4

You need to familiarize yourself with the Haversine forumla This will calculate the distances from lat and lon as you expected through mysql

Community
  • 1
  • 1
wesside
  • 5,622
  • 5
  • 30
  • 35
  • Thanks for your answer, +1. I'm going to try Shubhansh solution first, if that won't work I'll give your suggestion a try. – Ben Fransen Sep 18 '12 at 13:56