update set table1 fir set fir.a=(select name from table2 sec where fir.id_1=sec.id) and fir.b=(select name from table2 sec where fir.id_2=sec.id);想要做此更新多個字段應該如何寫sql?這個sql報ORA-00933 命令未正確結束
3 回答

冉冉說
TA貢獻1877條經驗 獲得超1個贊
實際上是語法錯誤。
同時更新多個字段,不是使用and連接,而是使用','逗號隔開。
所以,你這個語句的正確寫法是,把and改成,
update set table1 fir set fir.a=(select name from table2 sec where fir.id_1=sec.id) , fir.b=(select name from table2 sec where fir.id_2=sec.id);

qq_花開花謝_0
TA貢獻1835條經驗 獲得超7個贊
update table1 set RYMC = '人員名稱'||rownum;
你這樣試試,執行前備份一下table1里的數據,別不是你想要的結果
如果是全表修改不用加條件,如果不是的全表修改,比如只修改前50條
update table1 set RYMC = '人員名稱'||rownum where rownum<=50;

尚方寶劍之說
TA貢獻1788條經驗 獲得超4個贊
update set table1 fir
set (
fir.a=(select name from table2 secwhere fir.id_1=sec.id) ,fir.b=(select name from table2 sec where fir.id_2=sec.id)
);
- 3 回答
- 0 關注
- 773 瀏覽
添加回答
舉報
0/150
提交
取消