In today’s article, I will explain the use of the update clause and additionally the from clause to replace the records in our table with columns from a different table.
We have two separate tables below, and we will enter the büt columns of the ogrenci_büt table in the büt column of the ogrenci_u1 table.
We can use the following postgresql statement for the above-desired condition.
1 2 3 4 5 6 | UPDATE ogrenci_u1 u SET büt = b.büt FROM ogrenci_büt b WHERE u.adi=b.adi; |
In the picture above, we see that 9 records are affected, let’s see if our data has been transferred to the main table, the ogrenci_u1 table.