Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Make a calculated column and sort by it. The formula can be Googled for for short distances. For big ones - not just
If you do not want to deal with a rather complicated mathematical calculation, then it will be easier to create a separate table with distances: from, to and distance, and then recalculate using it. Well and accordingly each time to update.
Of course, you will lose on updates, but select will be very fast.
You can calculate, for this you will have to go through all the rows of the table and for each of the points calculate the distance to your point, and then sort it. But, if you need to select only a few nearest points or just points not too far from the given one, then you can use the bounding-box technique: imagine that there is a cube or square of a given size around the point and first calculate within the boundaries of the cube. This will allow you to somehow use the indexes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question