[英]postgis query to find neighbour
SELECT *
FROM offer
ORDER BY profile.location <-> "offer.profile.location"
我有2张桌子:一张是offer
,另一张是profile
。 offer
由用户在配置文件中提供的,所以在用户profile
如何查询找到最近的offer
使用PostGIS的PostgreSQL的?
这样的事情。 在这种情况下,假定SRID为4326,位置必须彼此相距5000米以内,并且提供的结果按距离排序。
SELECT offer.* FROM offer, profile
WHERE ST_DWithin(offer.location, profile.location, 5000)
ORDER BY ST_Distance(offer.location, profile.location);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.