以下是在後台更新易拓erp資料庫時遇到的乙個問題:
1.在db14資料庫中將料件號p44開頭,並且品名為"塑膠袋"的料件改為消耗性料件.這個簡單: update db14.ima_file set ima70 = 『y』 where ima01 like 『p44%』 and ima02 = 『塑膠袋』;
2.在以b021開頭的工單中,相應的下介料件的消耗性狀態也作相應變更. 這個麻煩涉及bmb表和ima表才能確定要更改的記錄(因為限定了品名).不能直接用update,最後寫了乙個儲存過程如下:最後,其實我也是傻了.單就解決現有問題而言完全可以:declare cursor my_table is (select bmb01,bmb03
from db14.bmb_file,db14.ima_file
where bmb03 = ima01
and bmb01 like 'b021%'
and bmb03 like 'p44%' and ima02 = '塑膠袋');
begin
for tab in my_table loop
update db14.bmb_file
set bmb15 = 'y'
where bmb01 = tab.bmb01 and bmb03 = tab.bmb03;
end loop;
end;
這樣一來要是還有相同條件下的其他表要更新的話,可直接在for loop裡面加上.
update db14.bmb_file set bmb15 = 'y'
where bmb01 like 'b021%'
and bmb03 in (select ima01
from db14.ima_file
where ima01 like 'p44%'
and ima02 = '塑膠袋');
聯合多表更新資料
正常思路 update t1 set t2.a select t2.a from t2 where t1.b t2.b 但是這樣執行之後會報錯 ora 01427 single row subquery returns more than one row 就是返回的值太多了,可能其中會包含一些重複行...
T SQL 之 多表聯合更新
1 sqlite 多表更新方法 update ta set col1 tb.col1 from tablea ta inner join tableb tb on ta.col2 tb.col2 這是乙個非常簡單的批量更新語句 在sqlserver中支援此語法 sqlite中卻不支援,sqlite中...
SQL Update多表聯合更新的方法
sql update多表聯合更新的方法 1 sqlite 多表更新方法 update t1 set col1 t2.col1 from table1 t1 inner join table2 t2 on t1.col2 t2.col2 這是乙個非常簡單的批量更新語句 在sqlserver中支援此語法...