The cause of the problem: we are doing fund projects to generate a lot of money on the home page display home information requirements to remove the extra 0 because we in the database design when the query return data such as 18.100000 this form and we need to remove the extra 0 form of presentation 18.1
Solution:
At first I saw that using the cast () function and the CONVERT () function is the real implementation of these two functions
How to use the error:
Using select CAST (90.090008700 as decimal) can also remove the 0 execution result after the decimal point to 90.09 after 0.000008700 is removed and the usage in this way is rounded
And in the data we're querying back, we don't know exactly what to do if we don't impose a mandatory number of digits. Specify decimal (parameter 1, parameter 2) the number of bits of the parameter two decimal places so this is not enough to solve this problem.
The right way to solve the problem:
Select 0+cast (90.09008700 as char) output 90.090087
Or
Select 0+convert (' 90.09008700 ', CHAR) output results: 90.090087
In both ways, you can get the data I want at the same time when we use the query sometimes in order to avoid the return of the data is null we can use Ifnull (parameter 1, parameter 2) parameter 1 value parameter 2 when the parameter is empty can specify what we want to return the value is more than I we commonly ifnull (c ount,0) This use method if count is empty returns 0
MySQL handles money after the decimal point 0 extra