MySQL FORMAT() 函數,將數字轉換為#,
,.
等格式,四捨五入到指定的小數位數,並將結果作為字串傳回,可用於檢索具有指定格式的列的十進位值的輸出。為了理解它,我們以表「estimated_cost」為例,其中包含以下資料-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)
以上是我們如何檢索具有指定格式的列的十進制值的輸出?的詳細內容。更多資訊請關注PHP中文網其他相關文章!