2017-01-27 53 views
-1

我有两个经纬度数据库。我需要比较并找出距离master数据库(数据库A)最近的点比较第二个数据库(数据库B)访问2016纬度经度查询

就像我有主数据6000(所有唯一),我需要运行第二个数据库(150数据)并从主数据库中找出最接近的150个坐标

回答

-1
 
You can use this query to find the distance between two points. For each point from DB1 find distance between points in DB2 and select min distance point. 

This Query will give distance in KM, 

Please note that this query you need to rewrite to make compatible with MSAccess DB. 

ROUND(
    (
     (
     (
      ACOS(
      SIN((from.latitude * PI()/180)) * SIN((to.latitude * PI()/180)) 
+ COS((from.latitude * PI()/180)) * COS((to.latitude * PI()/180)) 
* COS(((from.longitude- to.longitude) * PI()/180)) 
     ) 
     ) * 180/PI() 
    ) * 60 * 1.1515 
    ) * 1.609344, 
    2 
) AS distance