CAST() is useful for sorting ENUM columns in lexical order. : CAST : Cast Functions Operators MySQL TUTORIALS


MySQL TUTORIALS » Cast Functions Operators » CAST »

 

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>
mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Cast Functions Operators
» CAST