I have the database like as below structure. And how can I get location_id in list within 5 kilometer. There have latitude and longitude numbers are already in the database table. Please see my database structure image.
- school_id
- location_id
- school_name
- lat
- lng
Here is the database structure image:
I have already searched from this link
How to find nearest location using latitude and longitude from sql database?
and i don't understand the code.
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) *
cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin(
radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25
ORDER BY distance LIMIT 0 , 20;
No comments:
Post a Comment