UPDATE TABLE1 T1 SET T1.CENTERNAME=
(SELECT AC.CENTERNAME
FROM TABLE2 T2 INNER JOIN TABLET3 AN ON T2.CENTERID = T3.LOCATIONID
INNER JOIN TABLE1 T1 ON T3.LOG_ID = T1.LOGID W
HERE TRUNC(T1.ROW_DATE)='25-MAR-2014');
这会产生错误' ORA-01427:单行子查询返回多行'。
答案 0 :(得分:0)
错误消息
ORA-01427: single-row subquery returns more than one row
表示,呃,子查询返回的行多于行。也就是说,这部分内容......
(SELECT AC.CENTERNAME
FROM TABLE2 T2 INNER JOIN TABLET3 AN ON T2.CENTERID = T3.LOCATIONID
INNER JOIN TABLE1 T1 ON T3.LOG_ID = T1.LOGID
WHERE TRUNC(T1.ROW_DATE)='25-MAR-2014')
返回的不仅仅是行。发生错误是因为UPDATE的SET部分依赖于相等运算符 - SET T1.CENTERNAME=
- 因此它只能是一个值。
如果没有关于您的数据结构的更多细节,很难确定,但我怀疑您真正想要的是这样的
UPDATE TABLE1 T1
SET T1.CENTERNAME= (SELECT T2.CENTERNAME
FROM TABLE2 T2
INNER JOIN TABLE3 T3
ON T2.CENTERID = T3.LOCATIONID
WHERE T3.LOG_ID = T1.LOGID )
WHERE TRUNC(T1.ROW_DATE)='25-MAR-2014'
/
(我已整理你的修改以使别名保持一致。)