在處理提現操作時,遇到這樣一個問題:account_money為用戶剩余金額,提現之后要減去相應金額,需要用update語句進行運算,記錄一下
update之前數據庫數據(下邊所有的數據演示都是與前一步數據進行對比)
1、減法:
update money_user_bank set account_money=account_money-100 where id=1
結果:
2、加法:
1 update money_user_bank set account_money=account_money+100 where id=1
結果:
3、除法:
1 update money_user_bank set account_money=account_money/10 where id=1
結果:
4、乘法:
update money_user_bank set account_money=account_money*10 where id=1
結果:
5、如果要對整列進行操作則 '不加where' 條件即可,這里只演示加法,其他都一樣。
1 update money_user_bank set account_money=account_money+1000
結果: