I have two tables, one with all of the postcodes in the UK together with their latitudes and longitudes. The second is a table with store locations.
I need to create a fast search query that returns all stores(posts) within a user specified radius, together with their distances, in order from nearest to furthest away.
The table structure is:
Postcodes Table Fields: Id, Postcode, Latitude, Longitude
Locations Table Fields: Store Name, PostID, Lat, Lng
The search will return the post name and an extract of information relating to that store.
A query that gets the postcode the user submitted, gets the latitude and longitude of that from the Postcodes table, then runs a distance calculation between the Postcodes table latitude/longitude, and each of the Lat/Long in the locations, returning those within the user specified distance is what i imagine is required, but no luck on creating the distance calculations between the two sets of lat/lng.
Distances required are up to 10 miles, up to 20 miles, up to 50 miles, up to 100 miles, and over 100 miles.
Any help much appreciated.
Many thanks,
Dan