Skip to content
Advertisement

Select records within 5 kilometers with group by

I have an application that uses coordinates. I want to select records within 5 km that were thrown in the last 5 minutes. How can I do this easiest? I want to write a procedure. The values I will send to the procedure are latitude (float 11,8) and longitude (float 11,8).

Example table:

I found a query like this but can’t use group by.

EDIT:

For example. I am a customer and want to see the locations of vehicles within 5 km.

Advertisement

Answer

You can use ST_DISTANCE_SPHERE to calculate the distance between two points that are on a sphere.

The example from the MariaDB KB:

If you’re interested in the distance on a plane, use ST_DISTANCE.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement