鉴于以下表格:
Table1
| id | intermediate_id |
Itermediate
| id |
Table2
| id | intermediate_id | table1_id|
如何使用Table1.ids更新Table2?
我正在尝试以下方法:
update Table2
set table1_id =
(select table1.id
from table1
where table1.intermediate_id = table2.intermediate_id);
它给了我“错误:用作表达式的子查询返回的多行”
答案 0 :(得分:1)
update Table2
set table1_id = table1.id
from table1
where table1.intermediate_id = table2.intermediate_id