0
我想用case語句更新多個列,我實現了這一點,但它不是一個最好的方法,我必須做三次相同的任務,我怎麼能在一個語句中實現這裏是我的測試sql腳本:在mysql中使用case語句的更新表
Delimiter //
create procedure test_f()
begin
update test set
#### total####
test.total = case when test.currencyid='INR' then test.total/85.09
Else test.total End,
test.total = case when test.currencyid='SEK' then test.total/8.97
Else test.total End,
### Commission ####
test.commission = case when test.currencyid='INR' then test.commission/85.09
Else test.commission End,
test.commission = case when test.currencyid='SEK' then test.commission/8.97
Else test.commission End,
test.currencyid = case when test.currencyid in ('SEK','INR') then 'EUR'
Else test.currencyid End
WHERE test.currencyid in ('SEK','INR') ;
END //
現在我想基於currencyid完全更新所有三列。
我想更新總額,佣金和貨幣,如更新表測試集佣金= 123,總數= 123,currencyid ='歐元'其中currencyid ='歐元' – Developer