2
I have numbers in the database that are in the whole format. Ex:12345
I want to convert it to price format, in real ones. Ex: 12.345,00
2
I have numbers in the database that are in the whole format. Ex:12345
I want to convert it to price format, in real ones. Ex: 12.345,00
4
To return the formatted Mysql value, do so:
SELECT CONCAT('R$ ', FORMAT(valor, 2));
If you want to edit the value in PHP, you should use the function number_format
.
<?php
$valor = 12345;
$preco = 'R$' . number_format($num, 2, ',', '.'); // R$ 12.345,00
Friend, I want to make this direct conversion in sql query
@Mathdesigner47 I edited the answer.
@Mathdesigner47 Then you should remove the [tag:php] from your question.
Buddy, whatever you want
@Mathdesigner47 if the answer is correct, then mark it with the "green" sign below the dots arrow.
Browser other questions tagged mysql sql
You are not signed in. Login or sign up in order to post.
You want to convert column type or only format the result of the query?
– André Ribeiro
Only the query result
– Meeeefiu
Related: php number formatting
– rray