I select email across two tables as follows:
select email
from table1
inner join table2 on table1.person_id = table2.id and table2.contact_id is null;
Now I have a column in table2 called email
I want to update email column of table2 with email value as selected above.
Please tell me the update with select sql syntax for POSTGRES
EDIT:
I did not want to post another question. So I ask here:
The above select statement returns multiple rows. What I really want is:
update table2.email
if table2.contact_id is null with table1.email
where table1.person_id = table2.id
I am not sure how to do this. My above select statement seems incorrect.
Please help.
I may have found the solution:
Update a column of a table with a column of another table in PostgreSQL