在 mongoDB 中,有一个名为 geoNear 的命令,它返回到数据库中地理空间点存储的距离。另外,当我在 mongoDB 中使用 find 函数时,我可以使用近过滤器返回 DB 中 maxDistance 范围内的寄存器,例如:
db.collection.find( { localizacion:{ $near: { $geometry: { type: "Point", 坐标: [lng, lat]}}, $maxDistance: 1000}}).
该语句返回 DB 中距 [lng, lat] 1000 米的寄存器。
那么,MySQL中有类似的吗?
感谢您。
SELECT * WHERE st_distance_sphere(point_column, POINT(lng, lat)) < 1000
参考:
https://dev.mysql.com/doc/refman/en/spatial-convenience-functions.html#function_st-distance-sphere
https://dev.mysql.com/doc/refman/en/gis-mysql-specific-functions.html#function_point