How to sort mysql coloumn that has data in Bytes KB MB GB?
问题 I have a table with column 'size' that has file sizes in diff units like '10 Kb', '50 MB', '1 GB'. The problem is when I try to sort, it returns 1 GB row at first. How to solve this prob without changing old data ??? Any help is much appreciated... Thanks. 回答1: You should really either convert all data into a common unit (say bytes) or add a column which contains a "unit of measure" and keep the size column itself numeric. Having said that, the following should work on data in that ends with