Hello, I'll try to explain as best as I can. I got LAT and LONG of an address. I have another LAT and LONG for a different address, which is within 10 miles from the first one. I have a third LAT and LONG for a different address, which is within 20 miles from the first one. They are all stored in a mysql table. My table looks like this: id, LATI, LONGI, ADDRESS I need to return the address which is within 10 miles from the first one. What query should I use? The query should only return the second address, and not the third one. If I have the two, I can use Haversine formula to calculate the distance, but here I got only the first one and I need to find the ones (second, etc) which are within 10 miles. Thanks
Use MySQL's spatial extensions with GIS. A few examples (using spatial and other ways as well): http://stackoverflow.com/questions/4726031/mysql-latitude-and-longitude-table-setup http://stackoverflow.com/questions/1006654/fastest-way-to-find-distance-between-two-lat-long-points http://stackoverflow.com/questions/...-points-using-latitude-and-longitude-in-mysql https://www.google.com/search?safe=...or+php+mysql&oq=distance+calculator+php+mysql
Becareful with those links. There are a lot of bad answers on those forums. You don't want to perform a math operation column by column when retrieving records.