Mega Code Archive
CAST() is useful for sorting ENUM columns in lexical order
Normally, sorting of ENUM columns occurs using the internal numeric values.
Casting the values to CHAR results in a lexical sort:
mysql>
mysql> SELECT enum_col FROM tbl_name ORDER BY CAST(enum_col AS CHAR);
mysql>