Reputation: 913
Given the following tables:
Table1
| id | intermediate_id |
Itermediate
| id |
Table2
| id | intermediate_id | table1_id|
How do i update Table2 with Table1.ids?
I'm trying the following:
update Table2
set table1_id =
(select table1.id
from table1
where table1.intermediate_id = table2.intermediate_id);
which gives me "ERROR: more than one row returned by a subquery used as an expression"
Upvotes: 0
Views: 52
Reputation: 29717
update Table2
set table1_id = table1.id
from table1
where table1.intermediate_id = table2.intermediate_id
Upvotes: 1