Category Archives: PostgreSQL

insert into table using a select from another table

Following the update with data from another table, i am leaving this for quick reference. To insert data into table2 from table2: insert into table2 (field1,field2,field3) select table1.field1,table1.field2,table1.field3 from table1 (all the above is on the same line) We can make this as complex as needed.

update with join – another version – postgreSQL

This time its a second version of what i already posted, but might help some poor soul out there (and me, since i keep forgetting stuff). UPDATE “Patrimonio” SET x=st_x(“Morada”.geometry), y=st_y(“Morada”.geometry) FROM “Morada” WHERE “Patrimonio”.morada_id = “Morada”.”id” This example is specifically for PostgreSQL, acting on a geometry point column, but can easily, or almost directly,… Read More »