我不是很擅長SQL,我已經嘗試了一些東西。考慮到性能的代碼,將這5條更新語句合併爲一條語句的最佳方法是什麼?會是一個很大的幫助。非常感謝!合併多個SQL更新語句(甲骨文)
代碼:
----------------1
Update main_table
set a = (case
..some code.. end)
where condition_2;
----------------2
Update main_table
set b = (case
..some code.. end)
where condition_2
----------------3
Update main_table
set c = (select x from sec_table where conditon_1)
where condition_2
----------------4
Update main_table
set d = (select y from sec_table where conditon_1)
where condition_2
----------------5
Update main_table
set e = (select z from sec_table where conditon_1)
where condition_2
我已經嘗試過這一點,但我m尋找更好的表現: UPDATE main_table SET \t a =(CASE 部分代碼 END), \t B =(CASE 一些代碼 END), C = (選擇x FROM sec_table WHERE condition_2) d = (選擇Y FROM sec_table WHERE condition_2) e = (SELECT z FROM sec_table where condition_2) WHERE condition_1; – Vidit