[쥔장]=================================================================
mysql의 double 형과 decimal 간의 값 차이가 발생하는 것을 확인하고, double형을 decimal 형으로 형변환을 했다.
형변환하는 것이야 cast 함수를 사용하면 되지만, decimal로 했을 때의 사용에 대해 조금 더 설명을 한 것이 있어 참고한다.
=======================================================================
[http://stackoverflow.com/questions/11830509/cast-to-decimal-in-mysql]
8 2 | I am trying to cast to Decimal in MySQL like this:
I'm trying to convert the number of rows in a table (times 1.5) to a floating point number with two digits after the point. SQL code:
It produces an error:
Another try, this cast also doesn't work:
How do I use mysql to cast from integer to decimal? | |||
8 | From MySQL docs: Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC:
So, you are converting to a number with 2 integer digits and 0 decimal digits. Try this instead:
| ||||||||||||
|
5 | MySQL casts to Decimal:Cast bare integer to decimal:
Cast Integers 8/5 to decimal:
Cast string to decimal:
Cast two int variables into a decimal
Cast decimal back to string:
| ||
2 |
|
DECIMAL(12,2)
– ypercubeᵀᴹ Aug 6 '12 at 14:52