我正在尝试table1.column_name1
使用查询的数据结果进行更新
Select ID, column_name1
from table2
union
Select ID, column_name2
from table3
但我收到此错误:
ORA-01427: 单行子查询返回多于一行
请有任何建议,谢谢:)
使用以下数据表:
表格1
ID column_name1
----------------------------
26 null
30 null
34 null
表2
ID column_name1
---------------------------
26 fix
30 var
34 fix
表3
ID column_name2
----------------------------
26 fix
30 null
34 fix
期望的结果:
ID column_name1
-----------------------------
26 fix
30 var
34 fix
询问:
UPDATE table1
SET table1.column_name1 = (SELECT b.column_name1
FROM table1 f
JOIN
(SELECT ID, column_name1
FROM table2
UNION
SELECT ID, column_name2
FROM table3) b ON f.ID = b.ID);