MySQL FORMAT() function converts numbers into formats such as #,
,.
, rounds to the specified number of decimal places, and Returns the result as a string, which can be used to retrieve output with the decimal value of a column in the specified format. To understand it, let us take the table "estimated_cost" as an example, which contains the following data -mysql> Select * from estimated_cost; +----+-----------------+-----------+---------------+ | Id | Name_Company | Tender_id | Tender_value | +----+-----------------+-----------+---------------+ | 1 | ABC Ltd. | 110 | 256.3256879 | | 2 | Chd Ltd. | 116 | 8569.25647879 | | 3 | City group Ltd. | 202 | 23647.2365987 | | 4 | Hjkl Ltd. | 215 | 6598.327846 | +----+-----------------+-----------+---------------+ 4 rows in set (0.00 sec)
mysql> Select FORMAT(Tender_value,2) from estimated_cost; +------------------------+ | FORMAT(Tender_value,2) | +------------------------+ | 256.33 | | 8,569.26 | | 23,647.24 | | 6,598.33 | +------------------------+ 4 rows in set (0.00 sec)
mysql> Select FORMAT(Tender_value,1) from estimated_cost1; +------------------------+ | FORMAT(Tender_value,1) | +------------------------+ | 256.3 | | 8,569.3 | | 23,647.2 | | 6,598.3 | +------------------------+ 4 rows in set (0.00 sec)
The above is the detailed content of How can we retrieve the output of the decimal value of a column in a specified format?. For more information, please follow other related articles on the PHP Chinese website!