How might I convert a varchar
into a float
in MySQL while executing a query?
You cannot cast the value in mysql using float type.
The type can use following values:
So in your case you have to use decimal, e.g:
select cast(amount AS DECIMAL(10,2)) as 'float-value' from amounts
You can use this simple trick 0 + column_name
to convert it to float.
select 0 + column_name from table;
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