Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Distance between ALL locations per city

Hello,

I have a table with shop names, address, city, lat/long. I want to get the distances between all the shops per city.

That would mean:

City: Eindhoven

Shop 1 <-> Shop 2

Shop 1 <-> Shop 3

Shop 2 <-> Shop 3

. . . 

City: Amsterdam

Shop 2 <-> Shop 3

Shop 2 <-> Shop 4.

. . .

 

I'm using the Google Maps API through a function which takes the Origin & Destination to give the distance.

I was thinking about writing a FOREACH() statement which would check If city=city and then give distances between all the shops within that city but I'm not really sure how to build the part where it has to call the function.

 

I have tried running the function with Origin as concatinated lat/long and the Destination with the same but it returns 1 meter for every row, which means it is getting the distance from and to the exact same shop for every shop.

 

Any help would be very appreciated.

 

Kind regards,

Vasil Apostolov

3 Replies