在我开始对我的 Web 应用程序进行相当大的检修以使用空间查询之前,我想知道这个 MySQL 查询是否适用于 SQL Server 2008:
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) *
cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) *
sin( radians( lat ) ) ) ) AS distance
FROM markers HAVING distance < 25
ORDER BY distance LIMIT 0 , 20;
或者在 SQL Server 2008 中有没有更好的方法来做到这一点?
我的数据库目前存储日本军事基地附近的企业经纬度。但是,我正在查询表以查找包含指定基地 id 的企业。
Biz table
----------------------
PK BizId bigint (auto increment)
Name
Address
Lat
Long
**FK BaseId int (from the MilBase table)**
基于中心纬度/经度和给定半径(以公里为单位)的空间查询将更适合该应用程序,并将开辟一些新的可能性。
任何帮助是极大的赞赏!