0

what is the formula to find out the latitude and longitude of an address in MySQL? for example customer address is Freibergstrasse 23 12107. how can I find out its latitude and longitude?

Actually I need to know the distance between customer address and its book hotel address. I have hotel latitude and longitude and i need to know customer address longitude and latitude. I am using only MySQL.

bfontaine
  • 18,169
  • 13
  • 73
  • 107
  • Possible duplicate of [Calculate distance between two latitude-longitude points? (Haversine formula)](https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula) – Raymond Nijland Sep 28 '17 at 14:04
  • There is a MySQL implementation in the last comment just look for it. – Raymond Nijland Sep 28 '17 at 14:06
  • I dont have latitude and longitude column in my table. I have only address and postal code in my table. I need to findout latitude and longitude. Do you have any idea how to findout latitude and longitude? –  Sep 28 '17 at 14:07
  • You need to have a programming language to connect to a adress to latitude and longitude service. like Google https://developers.google.com/maps/documentation/geocoding/intro or the one Ndivhuwo used in this answer..it can't be done with only MySQL – Raymond Nijland Sep 28 '17 at 14:10
  • Thank you for suggesting me this link. –  Sep 28 '17 at 14:22
  • Are you trying to find the straight-line distance from two points or the driving distance? If you simply want to get the straight-line distance you will likely need to create a mysql function or stored procedure based off of the information similar to: https://stackoverflow.com/questions/1006654/fastest-way-to-find-distance-between-two-lat-long-points – user1934587390 Sep 28 '17 at 16:22

1 Answers1

0

Try using an API to get the coordinates from the address you have. For example if your program is web based you could use Map Quest API (Forward Geocoding). Your call will be something like this: http://www.mapquestapi.com/geocoding/v1/address?key=YourOwnRegistrationKey&outFormat=json&maxResults=1&location="Freibergstrasse 23 12107"

Ndivhuwo
  • 280
  • 2
  • 10
  • Actually i need to know the distance between customer address and its booked hotel address. I have hotel latitude and longitude and i need to know customer address longitude and latitude. I am not making a web program just using mysql. –  Sep 28 '17 at 13:58