Try something like this SELECT DISTINCT ON (boundary.d) boundary.* FROM boundary, location WHERE ST_Intersects (boundary.geom, location.geom)