I have 2 tables first with IDs second without IDs (I forgot it). Now I want to correct it.
I want to
insert IDs from 1st_table into 2nd_table into a new column where 1st_table.NAME = 2nd_tabl.NAME
How can I do this in posgresql?
CodePudding user response:
If you want to update datas in a table, you have to use Update
statement (https://www.postgresql.org/docs/14/dml-update.html).
You can do it this way:
update table2 set id = table1.id
from table1
where table2.name = table1.name