更新时间:2022-12-10 19:13:47
假设通过
插入"the_geom"纬度/经度值
您实际上的意思是更新 table2中的现有行:
UPDATE table2 t2
SET the_geom = t1.the_geom
FROM table1 t1
WHERE t2.address = t1.address
AND t2.the_geom IS DISTINCT FROM t1.the_geom; -- avoid empty updates
还要假设address
列具有UNIQUE
值.
优秀手册此处中有关UPDATE
的详细信息.. >
I have two tables.
Table1 contains companies whose locations are georeferenced with lat/lng coordinates in a column called the_geom
Table2 also contain the same companies from Table1, not georeferenced, along with hundreds of other companies whose addresses are georeferenced.
All I need to do is insert the_geom
lat/lng values from Table1 companies into their corresponding entries in Table 2. The common denominator on which these inserts can be based on is the address
column.
Simple question, I am sure, but I rarely use SQL.
Assuming that by
insert "the_geom" lat/lng values
you actually mean to update existing rows in table2:
UPDATE table2 t2
SET the_geom = t1.the_geom
FROM table1 t1
WHERE t2.address = t1.address
AND t2.the_geom IS DISTINCT FROM t1.the_geom; -- avoid empty updates
Also assuming that the address
column has UNIQUE
values.
Details about UPDATE
in the excellent manual here.