2017-01-27 56 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