IT_info
IT_info

Reputation: 727

Update a table from another table

I am using postgres and I have the following two tables. I would like to update the distinct_network_point table with the altitude value taken from the altitude_of_point table joining them on the id value.

The following is the distinct_network_point table:

enter image description here

The following is the altitude_of_point table:

enter image description here

How it shall be the structure of the sql query to do the job?

Upvotes: 2

Views: 122

Answers (2)

www
www

Reputation: 4391

I hope it helps:

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

Upvotes: 2

Raza Hussain
Raza Hussain

Reputation: 1

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

Upvotes: 0

Related Questions