2017-01-27 8 views
-1

私は緯度と経度の2つのデータベースを持っています。私はマスターデータベース(データベースA)から最も近い点を比較し、第2データベース(データベースB)を比較する必要がありますアクセス2016緯度経度のクエリ

私は6000(すべてユニーク)のデータをマスターに持っています。データ)を取得し、マスターデータベースから最も近い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