Skip to content
Advertisement

Adjusting values in MySQL based on current value

My database is for keeping track of user’s balances, and there are certain actions that will add or remove balance from the users. Currently I am doing this to get the balance and update it

JavaScript

Is there a way to directly do math within the query to add or remove? It is an integer.

Advertisement

Answer

Just do arithmetic:

JavaScript

You can hardcode the 100, but I think it is better to pass it in as a parameter.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement