Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Column: address | Type: Text
- Column: geo_point | Type: geometry(Point,4326)
- SELECT t.*, neighbor.* -- or only selected columns
- FROM tbl t
- LEFT JOIN LATERAL (
- SELECT *
- FROM tbl t1
- WHERE ST_DWithin(t.geo_point, t1.geo_point, 5000 * 1.609344)
- ) neighbor ON true
- WHERE t.address = 'my_address'; -- to restrict to a particular address
- CREATE INDEX tbl_geo_point_gist ON tbl USING gist (geo_point);
- SELECT t1.*, t2.* -- or only selected columns
- FROM tbl t1
- LEFT OUTER JOIN tbl AS t2
- WHERE ST_DWithin(t1.geo_point, t2.geo_point, 5000 * 1.609344);
Add Comment
Please, Sign In to add comment