Bug #12746 | Order By with enum fieds returns invalid order | ||
---|---|---|---|
Submitted: | 23 Aug 2005 5:21 | Modified: | 23 Aug 2005 12:25 |
Reporter: | Peter Volk (Basic Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 5.0.11, 4.1.13, 4.0.25 | OS: | Any (Any) |
Assigned to: | CPU Architecture: | Any |
[23 Aug 2005 5:21]
Peter Volk
[23 Aug 2005 5:27]
Peter Volk
the initial sql dump for the test
Attachment: peter.sql (text/plain), 93.34 KiB.
[23 Aug 2005 12:25]
MySQL Verification Team
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: From the MySQL manual: ENUM values are sorted according to the order in which the enumeration members were listed in the column specification. (In other words, ENUM values are sorted according to their index numbers.) For example, 'a' sorts before 'b' for ENUM('a', 'b'), but 'b' sorts before 'a' for ENUM('b', 'a'). The empty string sorts before non-empty strings, and NULL values sort before all other enumeration values. To prevent unexpected results, specify the ENUM list in alphabetical order. You can also use GROUP BY CAST(col AS VARCHAR) or GROUP BY CONCAT(col) to make sure that the column is sorted lexically rather than by index number.