MySQL Convert Bytes to Kilobytes, Megabytes, Gigabytes

后端 未结 4 2026
旧时难觅i
旧时难觅i 2020-12-11 02:28

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

4条回答
  •  温柔的废话
    2020-12-11 02:48

    select concat(round(data*1048576/1073741824,2),' GB')

    for example: 1024 = 1gb select concat(round(1024*1048576/1073741824,2),' GB') 1gb

提交回复
热议问题