MySQL Convert Bytes to Kilobytes, Megabytes, Gigabytes
问题 I have a logs table that stores various file sizes in bytes. I want to be able to query the database and return the smallest possible float which has been converted to MB GB etc. At present I can return the value in MB but how do I continue to divide further to smallest value and append the unit? SELECT CONCAT( ROUND( SUM( data_transferred ) /1048576, 2 ) , ' MB' ) FROM `logs` Any help would be appreciated. UPDATE: Based on the link voodoo417 provided I updated my query to the following,