Multiply Column by 1.0003 and then round result up to nearest whole number.
This is supposed to multiply the bank balance by 1.0003 and then always round the result up to the nearest whole number So, for instance, if you had 5,000 points in your account, this would multiply it by 1.0003 which would give you 5,001.5 Then the round() function should round this up to 5,002
UPDATE `accounts` SET `bank_balance` = `bank_balance` + ceiling(`bank_balance` * 1.0003) WHERE `user_id` = 1
However, what's happening is MySQL is just doubling the bank balance and adding 1 to it. So a balance of 5,000 turns into 10,001, for example.
How can I get it to round it like I want?
I'm unable to get the same results as you. In fact this simplified queries returns 5002 as expected:
And building a dummy table and running your query against it also produces the results you say you expect.
SELECT CEILING( 5000 * 1.0003 )
The only thing I can think is there is some other piece of information I'm not properly recreating.
CREATE TABLE EvenStar (
id int not null auto_increment primary key,
balance int not null
insert into EvenStar (balance) values (1000),(2000),(5000),(7000);
update EvenStar SET balance = balance + CEILING(balance * 1.0003);
SELECT * FROM EvenStar;
try converting balance to a float or double first.... perhaps you're coercing 1.0003 to become an integer somehow (in which case it will probably just be 1 and do nothing).
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)