我是音乐评论家,我想建立我的网站。 我已经在mysql中创建了一个数据库,其中有一列用于评级。 以下是可能性:10,9.5,9,8.5,8,7.5 ... 1,0.5和0
我可以使用什么样的柱子,现在我选择DECIMAL值为:3,1
问题是,当我输入9时,它返回9.0 ...有没有办法在列中存储整数和十进制数?
I'm a music reviewer and I want to build my website. I've built a database in mysql with a column for the ratings. Here are the possibilities : 10, 9.5, 9, 8.5, 8, 7.5 ... 1, 0.5, and 0
What kind of colum can I use, for now I choose DECIMAL with value of : 3,1
The problem is that when I enter 9, it returns 9.0 ... Is there a way to store Whole and Decimal numbers in a column?
最满意答案
为了格式化显示的数字,你可以用你正在解析mysql结果的任何语言进行那种处理。例如,在PHP中,你只需要转换为浮点并打印它。
$string = '9.0000000'; echo (float)$string;这将打印'9'。
For formatting the numbers for display, you would do that kind of processing in whatever language you were parsing the mysql results in. In PHP, for example, you would simply cast to a float and print it.
$string = '9.0000000'; echo (float)$string;This would print '9'.
更多推荐
发布评论