在oracle中,尝试更新同一个表中的列 - 例如,如果列的值为636180,则为3,如下所示
update TABLE_A
set wid = (
select distinct case wid
when 636180 then 3
when 636181 then 5
else wid
end new_wid
from TABLE_A where rownum < 100);
错误输出为
SQL Error: ORA-01427: single-row subquery returns more than one row
01427. 00000 - "single-row subquery returns more than one row"
请帮忙。
答案 0 :(得分:1)
update TABLE_A
set wid = case when wid = 636180 then 3
when wid = 636181 then 5
else wid
end
where rownum < 100
或仅更新具有相关wid
s
update TABLE_A
set wid = case when wid = 636180 then 3
when wid = 636181 then 5
end
where wid in (636180, 636181)