仅在逗号 mysql 后存储数字 [英] Store only numbers after Comma mysql
本文介绍了仅在逗号 mysql 后存储数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
mysql函数如何只保存逗号后的数字?
How to save only the numbers after the comma with mysql functions?
例如:16.03
----> 03
推荐答案
如果我理解正确,您需要数字的小数部分.在 MySQL 中,您可以使用 mod()
:
If I understand correctly, you want the fractional part of the number. In MySQL, you can do this with mod()
:
select mod(14.03, 1)
收益率为0.03".
Juhana 提出了一个很好的观点.MySQL 可以在数字和字符串之间自由转换,因此您可以在此使用 substr()
:
Juhana makes a very good point. MySQL freely converts between numbers and strings, so you can use substr()
on this:
select substr(14.03, locate('.', 14.03)+1)
如果您想要逗号后的数字,请将 '.'
替换为 ','
.
If you want the digits after a comma, replace '.'
with ','
.
这篇关于仅在逗号 mysql 后存储数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文