Organizational Research By

Surprising Reserch Topic

distance calculations in mysql queries

distance calculations in mysql queries  using -'php,mysql,distance'

I have to query a database of thousands of entries and order this by the distance from a specified point.

The issue is that each entry has a latitude and longitude and I would need to retrieve each entry to calculate its distance. With a large database, I don't want to retrieve each row, this may take some time.

Is there any way to build this into the mysql query so that I only need to retrieve the nearest 15 entries.


`SELECT, caclDistance($latlng, events.location) AS distance FROM events ORDER BY distance LIMIT 0,15`

    function caclDistance($old, $new){
       //Calculates the distance between $old and $new


asked Oct 7, 2015 by tushar2k6
0 votes

Related Hot Questions

Government Jobs Opening