Order by enum value
mysql>
mysql>
mysql> CREATE TABLE EmployeeS_SMALL
-> (EmployeeNO INTEGER NOT NULL PRIMARY KEY,
-> NAME CHAR(15) NOT NULL,
-> INITIALS CHAR(3) NOT NULL,
-> BIRTH_DATE DATE,
-> SEX ENUM ('M','F'));
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
mysql> INSERT INTO EmployeeS_SMALL
-> VALUES (24, 'Jones', 'P', '1985-04-22', 'M')
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO EmployeeS_SMALL
-> VALUES (25, 'Marx', 'L', '1981-07-01', 'F')
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO EmployeeS_SMALL
-> VALUES (111, 'Cruise', 'T', '1982-11-11', 'm')
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO EmployeeS_SMALL
-> VALUES (199, 'Schroder', 'L', '1970-02-12', 'X')
-> ;
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> INSERT INTO EmployeeS_SMALL
-> VALUES (201, 'Lie', 'T', '1972-02-12', NULL)
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM EmployeeS_SMALL;
+------------+----------+----------+------------+------+
| EmployeeNO | NAME | INITIALS | BIRTH_DATE | SEX |
+------------+----------+----------+------------+------+
| 24 | Jones | P | 1985-04-22 | M |
| 25 | Marx | L | 1981-07-01 | F |
| 111 | Cruise | T | 1982-11-11 | M |
| 199 | Schroder | L | 1970-02-12 | |
| 201 | Lie | T | 1972-02-12 | NULL |
+------------+----------+----------+------------+------+
5 rows in set (0.00 sec)
mysql>
mysql> SELECT EmployeeNO, SEX
-> FROM EmployeeS_SMALL
-> ORDER BY SEX;
+------------+------+
| EmployeeNO | SEX |
+------------+------+
| 201 | NULL |
| 199 | |
| 24 | M |
| 111 | M |
| 25 | F |
+------------+------+
5 rows in set (0.00 sec)
mysql>
mysql> DROP TABLE EmployeeS_SMALL;
Query OK, 0 rows affected (0.00 sec)
mysql>
Related examples in the same category