I have a set of geometry values (point values). I have another distinct geometry value (polygon). I want to find out which points are inside (contains) the polygon. Say, my polygon is B. And the set of points are: {A1, A2, A3...}. I want to check whether B contains A1 then A2 then A3 and so on. I can do it individually by ST_Contains. Such as:

select * from table1 where st_contains(B,A1)

But I don't want to check individually. I want to check for the whole set at a time, i.e {A1, A2, A3...} and want to find out the points (i.e A3 and/or A2) which are contained in B means which has given true value for ST_Contains. How to do it?

  • 2
    Please edit the question to provide the SQL which is not working within the question, along with the exact error.
    – Vince
    Commented Dec 23, 2016 at 16:12
  • 1
    Please provide more information about the problem you are encountering and, as Vince has commented, the SQL that is not working. Please edit the question to include this extra information.
    – Midavalo
    Commented Dec 23, 2016 at 17:16
  • @Midavalo I have edited the question and elaborately explained my question. I think now it is cleared. Can it be reopened now?
    – LSG
    Commented Dec 29, 2016 at 10:59
  • any more answers??
    – LSG
    Commented Jan 3, 2017 at 11:39
  • Please, do not forget about "What should I do when someone answers my question?"
    – Taras
    Commented Feb 16, 2022 at 14:55

2 Answers 2


You can find the points in one table that are within the polygons of another table with this statement:

FROM table1, table2
WHERE ST_Contains(table1.geom, table2.geom)
  • @LSG is this the answer you were looking for?
    – kttii
    Commented Jan 10, 2017 at 14:14

You could use the following simple query to get all polygons with their associated points inside. Or reduce the points only to one polygon using a WHERE clause.

 SELECT pol.gid, pol.name, pol.area, poi.gid, poi.name
   FROM polygons pol, points poi
  WHERE st_intersects(pol.the_geom, poi.the_geom) AND pol.name ilike 'Time Square';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.