Sorry for the ambiguous title. This is not a duplicate from MySQL - Find points within radius from database . Here is the detailed problem:
I have a location database with indexed latitude and longitude values. I can freely add index and indexed computed column if needed.
I will be given a coordinates point and a distance (5km for example), I need:
Returns all points within 5km of the point.
OR if it is simpler, all points within a 5km-sided square on the map.
The requirement is for the database lookup operation to be as simple as it can. The precision is not at top priority. The result may be refined later at client-side, so it is preferably to return more result from server if needed.
The database I am using is SQL Server if it matters.
EDIT: Sorry I forgot another problem when posting the 1st post. I have another similar question:
Same rule applied, either circular or squared shape, now each target point has its own radius too. Let's say, point A has Lat, Lng and Radius properties and so on for B and C. Now I need to extract the points that has its shape collides with the source shape.