Sorting a MySQL string column as a number

Posted on 01-07-2017 by Nadir Latif


To sort a MySQL string column containing a number we can use the SUBSTRING and CAST functions. The SUBSTRING function should extract the numbers inside the string. The CAST function will convert the extracted string to a number.