Use ALTER TABLE to convert the name column to an ENUM that lists the colors in the desired sort order:
mysql>
mysql> CREATE TABLE color (name CHAR(10));
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> INSERT INTO color (name) VALUES ('blue'),('green'),('indigo'),('orange'),('red'),('violet'),('yellow');
Query OK, 7 rows affected (0.00 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql>
mysql> ALTER TABLE color
-> MODIFY name
-> ENUM('red','orange','yellow','green','blue','indigo','violet');
Query OK, 7 rows affected (0.02 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql>
mysql> SELECT name FROM color ORDER BY name;
+--------+
| name |
+--------+
| red |
| orange |
| yellow |
| green |
| blue |
| indigo |
| violet |
+--------+
7 rows in set (0.00 sec)
mysql>
Related examples in the same category