Bug #13088 Documentation Bug for the ENUM field
Submitted: 9 Sep 2005 15:35 Modified: 9 Sep 2005 19:17
Reporter: Peter Volk (Basic Quality Contributor)
Status: Closed
Category:Server: Docs Severity:S3 (Non-critical)
Version: OS:
Assigned to: Paul DuBois Target Version:
Triage: D4 (Minor)

[9 Sep 2005 15:35] Peter Volk
Description:
There is a documentation but at http://dev.mysql.com/doc/mysql/en/enum.html on the end of
the page that descibes how to sort an enum field by the real value and not by the index of
the entry. There it says

 GROUP BY CAST(col AS VARCHAR)

A casting to VASRCHAR is not possible. 

How to repeat:
Read and try

Suggested fix:
Change :
 GROUP BY CAST(col AS VARCHAR)

to:
  GROUP BY CAST(col AS CHAR)
[9 Sep 2005 16:19] Valeriy Kravchuk
mysql> create table te(c1 enum('b', 'a'));
Query OK, 0 rows affected (1.17 sec)

mysql> insert into te values ('a'), ('b');
Query OK, 2 rows affected (0.13 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from te order by c1;
+------+
| c1   |
+------+
| b    |
| a    |
+------+
2 rows in set (0.08 sec)

mysql> select * from te order by cast(c1 as char);
+------+
| c1   |
+------+
| a    |
| b    |
+------+
2 rows in set (0.01 sec)

mysql> select * from te order by cast(c1 as varchar);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'varch ar)' at
line 1
[9 Sep 2005 19:17] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).