I have a Mysql table,
I want to sort the values in the table by size of the meta_value
from biggest to smallest.
Look at the order of the value?
How come 150,000,000
is smaller than 1,555,555
.
I have a Mysql table,
I want to sort the values in the table by size of the meta_value
from biggest to smallest.
Look at the order of the value?
How come 150,000,000
is smaller than 1,555,555
.
Meta_value is a CHAR column, not a number column. If your meta value comes from another data source then you will need to use natural sorting, and you can use ORDER BY LENGTH(alphanumeric), alphanumeric
If you have control over the content in meta_value you could consider modifying the column data type to int or numeric or some other numeric data type. Then you would get the sort you expect. However, changing a data type with existing data runs the risk of encountering non-standard data, so you need to know exactly what values are in that column.