In PostgreSQL, we may want to update the records from another table, for this we will use the update clause, but this time we will add the word FROM.
We have two separate tables below, we will enter the data in the büt columns of the ogrenci_u1 table in the büt column of the ogrenci_büt table.
You can use the following plpgsql statement for the desired condition above.
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.
As seen above, we have added the büt grades of the students in the student_büt table to the büt column.