如何使用经度和纬度从SQL数据库中找到最近的位置?
问题描述:
我想从以下数据库表中找到最近的位置
I want to find a nearest location from following database table
Address Latitude longitude
Kathmandu 44600, Nepal 27.7 85.33333330000005
Los, Antoniterstraße 37.09024 -95.71289100000001
Sydney NSW, Australia 49.7480755 8.111794700000019
goa india 15.2993265 74.12399600000003
我从Google地图中提取了所有数据。
在这里,我必须从一个地方找到最近的位置。
假设我在Surkhet的地方,它的纬度是28.6,经度是81.6,
我怎么能从Surkhet那里找到最近的地方。
I have fetched this all data from google maps. Here i have to find nearest location from a place. Suppose i am at place Surkhet its latitude is 28.6 and longitude is 81.6, how can i find nearest place from the place Surkhet.
答
SELECT id,(3959 * acos(cos(弧度(37))* cos(弧度(lat))* cos(弧度 - 弧度(-122))+ sin(弧度(37))* sin(弧度(lat))))AS距距标记距离< 25 ORDER BY distance LIMIT 0,20;
这是最佳查询