Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir Or Madam

I have to use round function in my sql query to round the result for 2 decimals.

Here is my query.

$RES=mysql_query("update Pyament set Received=Received+$GrandTotal, salereceived=salereceived+$GrandTotal where M_id=1 and G_id=1")


I want to use round function to update Received and salereceived.

please help me.
Posted
Comments
Sergey Alexandrovich Kryukov 6-Aug-14 2:44am    
Rounding is a pretty bad thing as it can cause loss of precision and even accumulate such loss. Why doing that?
—SA
Rajkumar_007 6-Aug-14 3:29am    
because without round updated values in database is just like 32.21546844 this so i want to use round function or any function which help to send data like 32.15 this no.

1 solution

Use Round
SQL
update Payment set Received = Round(Recieved +$GrandTotal, 2) , salereceived =  Round(salereceived+$GrandTotal, 2)


I think

?
 
Share this answer
 
Comments
CPallini 6-Aug-14 2:44am    
I think is good.
Neetin_1809 6-Aug-14 15:09pm    
You Can Use parseFloat(utVariableName).toFixed(2); for rounding through javascript/jquery.

Let Me Know it this the thing you were searching for ?

Happy Coding .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900