postgresql 9.6, postgis 2.3
Following this Select features that do NOT intersect in PostGIS, I would like to compare one table to itself, to keep all records from table p1, even and above all those that don't have any record matching in table p2.
Actually I want to keep features that don't intersect any.
edit : code updated
select p1.gid, p2.gid from table p1 left join table p2 on st_intersects(p1.geom, p2.geom) and p1.gid <> p2.gid where p2.gid is null ;
Without the and, All that I get are matching records : the left seems to be ignored.
With the and condition, no result. Where is (are) my mistake(s) ?