SQL语句实现根据经纬度计算距离并排序分页

 SELECT *,(round(6367000 * 2 * asin(sqrt(pow(sin(((latitude * pi()) / 180 - ({$userLatitude} * pi()) / 180) / 2), 2) + cos(({$userLatitude} * pi()) / 180) * cos((latitude * pi()) / 180) * pow(sin(((longitude * pi()) / 180 - ({$userLongitude} * pi()) / 180) / 2), 2))))) AS distance FROM `table_distance` ORDER BY distance asc  LIMIT 2,10;

SQL语句实现根据经纬度计算距离并排序分页_第1张图片

你可能感兴趣的:(SQL)