访问2016年纬度经度查询

时间:2017-01-27 05:54:12

标签: sql ms-access

我有两个具有纬度和经度的数据库。我需要比较并找出主数据库(数据库A)中比较第二个数据库(数据库B)的最近点

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

1 个答案:

答案 0 :(得分:-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