I need to set the "Total Price" value to be a two decimal point value like "56.35". Now it's showing fraction values like "56.3566666". I need it to be formatted by MySQL "SELECT" query.
select
format(field, 2) as formatted
from
table
Do note that Format() returns a string, and the result will be with two decimal places (in the above example) - i.e. 100 will be formatted as 100.00.
Documentation.
That works too, but if you need it for further calculations or what not AND you have MySQL > 5.0.8 you could also try:
select
cast(field as decimal(14, 2)) as formatted
from
table
It is a bit more flexible this way! I like flexible...
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