How do I select only the part of the value of a number to the right of the decimal point?
So for example:
SELECT ____(10.1234) AS mynumber;
Where the result would be:
.1234 (or 1234)
The MOD function should work:
SELECT MOD(10.1234, 1); -- -> 0.1234
You can also use below...
select substring_index(field1,'.',1), substring_index(field1,'.',-1) from table1;
Sample output
mysql> select substring_index(120.45,'.',1), substring_index(120.45,'.',-1) ; +-------------------------------+--------------------------------+ | substring_index(120.45,'.',1) | substring_index(120.45,'.',-1) | +-------------------------------+--------------------------------+ | 120 | 45 | +-------------------------------+--------------------------------+ 1 row in set (0.00 sec)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With