Find distance between two zip codes OR Find distance between two latitude and longitude


latitude = 51.237159

longitude =  6.737445

SELECT zipcode, city, country, ( 6371 * acos( cos( radians( latitude ) ) * cos( radians( latitude_field_name ) ) * cos( radians( longitude_field_name ) – radians( longitude ) ) + sin( radians( latitude ) ) * sin( radians( latitude_field_name ) ) ) ) AS distance
FROM table_name

zipcode city country latitude longitude distance
40547 Düsseldorf Germany 51.237159 6.737445 0
40570 Dusseldorf Germany 51.198531 6.735061 4.29844576108689
41464 Neuss Germany 51.186067 6.692292 6.49371210989321
41564 Kaarst Germany 51.215095 6.636164 7.46730953495452
41468 Neuss Germany 51.169475 6.748088 7.56255673166281
40625 Düsseldorf Germany 51.234292 6.861356 8.63270963507461
40599 Düsseldorf Germany 51.177089 6.867331 11.2467526264088
47809 Krefeld Germany 51.331328 6.626299 13.0152304362707
40593 Düsseldorf Germany 51.156245 6.885656 13.6968761245336

If you have any query then feel free to contact me at Jainish Senjaliya

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s