我有一张表 hotspots
id name date
1 foo 2011-06-15 15:10:34
2 bar 2011-07-02 16:45:18
还有一个表locations
hotspotid zipcode latitude longitude
1 90001 xxxxx xxxxx
2 45802 xxxxx xxxxx
我如何使用 SQL 查询列出特定经度和纬度附近的热点?
附言我想要一个纯 SQL 解决方案,但如果需要,php 也可以。
谢谢
最佳答案
首先,您需要每个热点的地理位置,最好使用纬度和经度。您可以使用 Google Geocoding API遍历每条记录并存储纬度/经度。
然后你可以match nearby hotspots with this SQL query并按距离排序。
希望对您有所帮助。
关于php - 使用纬度和经度获取最近的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6560373/