Bug #64524 | Incorrect order when quoting an ORDER BY aliased column. | ||
---|---|---|---|
Submitted: | 2 Mar 2012 13:48 | Modified: | 2 Mar 2012 14:21 |
Reporter: | Van Stokes | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 5.5.19 x64 | OS: | Linux (Ubuntu 11.10 x86_64) |
Assigned to: | CPU Architecture: | Any | |
Tags: | alias, order by, quote |
[2 Mar 2012 13:48]
Van Stokes
[2 Mar 2012 14:21]
Valeriy Kravchuk
Looks like a duplicate of bug #29199. 'name' is considered as string constant, not alias/name/identified, thus the results. Moreover, our manual clearly explains this at http://dev.mysql.com/doc/refman/5.5/en/problems-with-alias.html: "In the select list of a query, a quoted column alias can be specified using identifier or string quoting characters: SELECT 1 AS `one`, 2 AS 'two'; Elsewhere in the statement, quoted references to the alias must use identifier quoting or the reference is treated as a string literal. For example, this statement groups by the values in column id, referenced using the alias `a`: SELECT id AS 'a', COUNT(*) AS cnt FROM tbl_name GROUP BY `a`; But this statement groups by the literal string 'a' and will not work as expected: SELECT id AS 'a', COUNT(*) AS cnt FROM tbl_name GROUP BY 'a'; "