如何使用经度和纬度从SQL数据库中找到最近的位置? [英] How to find nearest location using latitude and longitude from sql database?

查看:97
本文介绍了如何使用经度和纬度从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;

这是最佳查询

这篇关于如何使用经度和纬度从SQL数据库中找到最近的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆