Answer the question
In order to leave comments, you need to log in
How to correctly calculate the distance between objects?
Good afternoon, I
installed mysql 5.7 > I found ST_Distance_Sphere there, but I can’t figure out how to calculate the distance for everyone. In general, I have a table where I need to compare one user with the rest and display all who have a distance of no more than 10 miles.
I'm trying to )))
SELECT * FROM `profile` WHERE (ST_Distance_Sphere(
(SELECT geo FROM profile WHERE user_id = 9972),
(SELECT geo FROM profile WHERE user_id > 200000)
))
Answer the question
In order to leave comments, you need to log in
MySQL learned to pass nested queries in a function? How do you imagine it. Make a selection with a normal join first, then do a WHERE. Here, in any case, each muscle will not build indexes for each muscle and you will have to bypass all the stored data.
something you have is completely overhead, I somehow wrote a similar task on sqlite without built-in functions for working with geodata, nothing complicated, it worked quickly
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question