SQL query: insert values into polygon where features of the polygon intersects another polygon [closed]

dba.stackexchange https://dba.stackexchange.com/questions/286661

  •  17-03-2021
  •  | 
  •  

Question

I'm very new to sql so I apologize in advance for my very dummy question...

I'm looking for a way to insert into a table A some values stored in another table B only for the features of table A that intersects features of table B.

I tried this:

insert into schema.table_A(columnKJ1)
select "columnPO4" from schema.table_B
WHERE table_A.geom.STintersects(table_B.geom) = 1

but I get this error message: cross-database references are not implemented

What is the right way to do that please ?

Was it helpful?

Solution

You're not allowed to reference table_A in the insert inside the select. The query needs to work stand-alone.

The following should work (untested):

insert into schema.table_A(columnKJ1)
select "columnPO4"
from schema.table_B
join schema.table_A on st_intersects(table_a.geom, table_B.geom);
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top