I'm trying to create a new table with a list of each address in another table and it's 10 nearest addreses. Each record has latitude and longitude. Clearly running all against all is much more work than is needed (several million records).
However it occurred to me if I resorted/indexed the table using latitude, longitude it would then sort by distance automatically and I could just step through each record doing ID+/- 25.
However this still leaves me with the question; what would the query to find the distance between two records each having latitude/longitude look like?