Home > Software design >  How to query all polygon has 1 point into
How to query all polygon has 1 point into

Time:12-30

I have 2 table postgresql postgis 1 table polygon (A,B,C,D) and 1 table point (1,2,3,4) I want to query select all polygon has contain point (A,B,C) How can i do it.

enter image description here

CodePudding user response:

You can use the where exists clause to select the polygons if there 1 or more point inside:

SELECT *
FROM myPolygonLayer p
WHERE EXISTS (
 SELECT 1 
 FROM myPointLayer pt
 WHERE st_intersects(p.geom, pt.geom)
)
  • Related