小五哥
发布于

MySQL 通过经纬度查询附近的目标

  SELECT name, latitude, longitude, SQRT(
    POW(69.1 * (latitude - [target_lat]), 2) +
    POW(69.1 * ([target_lng] - longitude) * COS(latitude / 57.3), 2)) AS distance
FROM TableName 
HAVING distance < [distance]
ORDER BY distance;
浏览 (24)
点赞
收藏
评论