1
I have a table that has the coordinates (latitude and longitude) of the users.
How do I make a query to bring who is closest to the location.
Ex:
ID | Lat | Long
1 | -22.874428 | -43.372334
2 | -20.292799 | -40.301991
Bring these two where id 2 would be closest (search coordinates: -20.292799 | -40.301991)
I’d like the consult to bring something like
ID | Distancia
1 | 2km
2 | 20km
- 2km and 20km would be calculated within the sql query
Do you have the reference coordinate data? And you know how to calculate the distance using coordinates?
– Woss
I have the data yes, for example: -20.292799 | -40.301991. I can’t calculate the distance.. :/
– Leandro Marzullo
This one only brings the specific distance, I need to bring the query a column with distance, so you can make the ordering, I will edit the question to get better, thank you.
– Leandro Marzullo
What is the value of the origin? Well, how will you calculate the distance if you do not know where it starts? Would this distance be in a straight line right? And not using a street system to check the distance, right?
– David