kc melec
kc melec

Reputation: 17

Using SQL to increase a field value by a set percentage of the original value

How can i set balance to be balance + 2% (two percent of balance)

I have tried to do the following:

UPDATE users SET balance = balance + 2 '%';

but it didn't work.

Also tried this:

UPDATE users SET balance = balance + 2%;

It still didn't work.

Upvotes: 1

Views: 669

Answers (1)

TAHER El Mehdi
TAHER El Mehdi

Reputation: 9243

Simply 2% represent 2 of 100%

-- 2% = balance * (2/100)
UPDATE users SET balance = balance + balance * (2/100);

Upvotes: 3

Related Questions