我是oracle的新手,我想更新列id = 1 , 2
中的多个行值。
我试过了:
update Tester
set employee_phone_number = ( 0789456123,0789456321)
where employee_id in (1,2);
但它给了我“缺少右括号”
任何帮助,请提前感谢。
答案 0 :(得分:3)
另一种方法:
merge into
tester
using (
select 1 id,'0123456785' employee_phone_number from dual union all
select 2 id,'0123456786' employee_phone_number from dual) new_values
on (
tester.id = new_values.id)
when matched then update
set employee_phone_number = new_values.employee_phone_number;
更多的单词,但允许仅在一个地方指定值,并扩展为允许id尚不存在的插入。
答案 1 :(得分:2)
请改为尝试:
update Tester
set employee_phone_number = CASE WHEN employee_id = 1 THEN 0789456123
WHEN employee_id = 2 THEN 0789456321
END
where employee_id in (1,2);