Reputation: 149
I'am a newbie.. I'm sorry if my question is repost.. i want to ask how to get value front of decimal on mysql..
here my fiddle example
i try to use FORMAT
on mysql
`SELECT FORMAT(desc,0) FROM table1`
the result is round.. in my case i dont want the result rounded.
i want the result is
1. 9
2. 9
3. 11
4. 11
sorry if i'm wrong.. thanks for help..
Upvotes: 1
Views: 226
Reputation: 46900
FLOOR it.
SELECT id, FLOOR(desc) FROM table1
This will remove the decimal places and return that whole number which you are looking for.
Result
- 9
- 9
- 11
- 11
Upvotes: 2
Reputation: 496
use round().. get all the data from your sql database then loop it
for example you have
$number = "1.00";
or
$number = 1.00;
then use round()
echo round($number);
the output is 1
Upvotes: 0
Reputation: 7189
you can also use ROUND
to truncate decimal places
SELECT ROUND(@column_name,0,1)
OR
example select CAST(Round(MySum * 20.0 /100, 0) AS INT)
91 * 20 / 100 => 1820 / 100 => 18 (truncated from 18.20)
Upvotes: 0