Guest User

Untitled

a guest
Jun 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Column: address | Type: Text
  2. Column: geo_point | Type: geometry(Point,4326)
  3.  
  4. SELECT t.*, neighbor.* -- or only selected columns
  5. FROM tbl t
  6. LEFT JOIN LATERAL (
  7. SELECT *
  8. FROM tbl t1
  9. WHERE ST_DWithin(t.geo_point, t1.geo_point, 5000 * 1.609344)
  10. ) neighbor ON true
  11. WHERE t.address = 'my_address'; -- to restrict to a particular address
  12.  
  13. CREATE INDEX tbl_geo_point_gist ON tbl USING gist (geo_point);
  14.  
  15. SELECT t1.*, t2.* -- or only selected columns
  16. FROM tbl t1
  17. LEFT OUTER JOIN tbl AS t2
  18. WHERE ST_DWithin(t1.geo_point, t2.geo_point, 5000 * 1.609344);
Add Comment
Please, Sign In to add comment