Postgres 9.3 copy data from another table with relation Hi I have two tables in my database which is related, which is forms and qa_forms.

forms
-&gt;id
-&gt;name
-address
-phone
-calldatetime


and then `

qa_forms
-&gt;id
-&gt;forms_id
-&gt;name
-&gt;address
-&gt;phone


So the qa_forms is just the replicate of forms I already have data on both however I forgot to add calldatetime in my qa_forms. So what I did is i add new column on qa_forms which is calldatetime. As expected all the values will be null since I already have data before and this one is newly added, how can I get their respective calldatetime on forms on the fastest way I can do it? They have relation which is forms.id = qa_forms.forms_id.

Any query on that?
I think something like this would work -- let me know if it doesn't

WITH forms_data AS (
  SELECT id, calldatetime FROM forms
) UPDATE qa_forms qf
  SET calldatetime = fd.calldatetime
  FROM forms_data fd
  WHERE qf.id = fd.id;


Edit (better version, suggested by dezso):

UPDATE qa_forms qf
SET calldatetime = f.calldatetime
FROM forms f
WHERE qf.id = f.id;