- SELECT
- geo_id, `name`,(
- 6371 * acos (
- cos ( radians(".$_POST['lat'].") )
- * cos( radians( lat ) )
- * cos( radians( lng ) - radians(".$_POST['lng'].") )
- + sin ( radians(".$_POST['lat'].") )
- * sin( radians( lat ) )
- )
- ) AS distance
- FROM geo
- HAVING distance < 20
- ORDER BY distance
- LIMIT 0 , 20;
复制代码 基于公里km
|