从另一个表更新表

时间:2013-03-01 10:51:47

标签: sql postgresql sql-update insert-update

我正在使用postgres,我有以下两个表。我想更新distinct_network_point表,其中包含从altitude_of_point表中获取的高度值,并将其与id值相连接。

以下是distinct_network_point表:

enter image description here

以下是altitude_of_point表:

enter image description here

如何使用sql查询的结构来完成这项工作?

2 个答案:

答案 0 :(得分:2)

我希望它有所帮助:

UPDATE distinct_network_point 
SET altitude = altitude_of_point.altitude 
FROM  altitude_of_point 
    WHERE distinct_network_point.id= altitude_of_point.id

答案 1 :(得分:0)

UPDATE distinct_network_point 
SET altitude = altitude_of_point.altitude 
FROM distinct_network_point,  altitude_of_point 
    WHERE distinct_network_point.id= altitude_of_point.id
相关问题