开发者

How to increase numbers in mysql column

I am creating a bank simulation game and have the cron job working to run my php开发者_C百科 script every 30 minutes for each "game day".

I have a column, "account_balance" on "player_accounts" table and I would like for that value to increase by x% when each game day is processed.

Basically need to take the current balance and multiply by 1.015 for example so the end result is the principle plus added interest.


Multiplication is a term:

UPDATE player_accounts SET account_balance = account_balance * 1.015


update account_balance set Amount=(Amount + Amount*(percent/100))

here is your answer


You just need to update the column's value by the percentage you want; for example:

update table_name
set col_a=col_a+(col_a*0.10)

That's it. It will add 10% to col_a in the table.

if you want to target specific rows, you can simply add a where condition:

update table_name
set col_a=col_a+(col_a*0.10)
where col_x=some_condition
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜