我从mysql收到此错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'long) *pi()/180 / 2), 2) ))as distance FROM wp_places_locator dest having dista' at line 1
使用此查询时:
set @orig_lat=121.9763; set @orig_lon=37.40445;
set @dist=10;
SELECT *,3956 * 2 * ASIN(SQRT(POWER(SIN((@orig_lat -abs(lat)) * pi()/180 / 2),2) + COS(@orig_lat * pi()/180 ) * COS(abs(lat) *pi()/180) * POWER(SIN((@orig_lon - long) *pi()/180 / 2), 2) ))as distance
FROM wp_places_locator dest having distance < @dist
ORDER BY distance limit 10\G;
从这里改编代码:http://arubin.org/files/geo_search.pdf在我的数据库中搜索它将接收的坐标附近的地理位置坐标,并按照距收到的坐标的距离顺序对它们进行排序。 任何帮助都会非常感激。