How can I figure out a users postal code if I have their latitude / longitude location? Need help w
- by mike
I'm using HTML5 geolocation to collect the users lat / long and I need to figure out what their postal code is as well. I have a database of all the lat / long for each postal code in the US & Canada. How can I write a query to find out what their postal code is? Below, is an example of how the data is structured in the 'zips' table.
Country PostalCode Latitude Longitude
USA 0051 40.813078 -73.046388
USA 00616 18.426456 -66.673779
I can't do a 'SELECT PostalCode FROM zips WHERE Latitude = user.lat AND Longitude = user.long'. I believe I need to find the nearest lat / long. Any suggestions on how I can write this?