2

Is there a way to delete data in one table that intersects the geomety of another table? I am using PostGIS.

Effectively I would like to do the following, but this returns an error.

DELETE FROM table_A
WHERE st_intersects(table_A.geom, table_B.geom)
4

You need to reference the second table with USING:

DELETE FROM table_A AS a
USING table_B AS b
WHERE ST_Intersects(a.geom, b.geom);

See the docs under 'Notes' for details.

  • Nice and straightforward and it works perfectly, thank you! – ste_j May 24 '18 at 16:19
  • @ste_j happy to help. care to accept? (wait for 24h according to the boards recommendations, but...) – ThingumaBob May 24 '18 at 16:22
  • @ste_j ;) cheers – ThingumaBob May 24 '18 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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