【发布时间】:2020-12-25 15:00:27
【问题描述】:
我正在尝试将下面的 Sybase 查询转换为 Oracle 查询。
update Student set st.age = (case when st.promoted != 'fail' then 1
else (select sc1.age from school sc1 where st.id = sc1.id ) END)
from Student st ,School sc
where st.id = sc.id
AND st.status in('1','7','2','5')
AND st.currentClass = sc.currentClass
AND st.currentCource = sc.currentCource ;
但我尝试在转换后执行以下 Oracle 查询,但出现以下错误。
update Student st set st.age = (select (case when st.promoted != 'fail'
then 1
else (select sc1.age from school sc1 where st.id = sc1.id ) END)
from School sc
where st.id = sc.id
AND st.status in('1','7','2','5')
AND st.currentClass = sc.currentClass
AND st.currentCource = sc.currentCource )
where exists
(select 1 from School sc1
where st.id = sc1.id
AND st.status in('1','7','2','5')
AND st.currentClass = sc1.currentClass
AND st.currentCource = sc1.currentCource);
查询返回:ORA-01427 单行子查询返回多于一行。有谁请帮忙
【问题讨论】:
标签: sql oracle join sql-update subquery