Bug #188 Alias name matching column name
| Submitted: | 24 Mar 2003 23:57 | Modified: | 25 Mar 2003 2:32 |
|---|---|---|---|
| Reporter: | Peter Zaitsev (Basic Quality Contributor) | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 4.0.13 | OS: | Any (All) |
| Assigned to: | CPU Architecture: | Any |
[24 Mar 2003 23:57]
Peter Zaitsev
[25 Mar 2003 2:32]
Michael Widenius
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 If you are using an alias that is the same name as an existing column the behaviour is not defined. Anyway, in all your examples, MySQL is NOT using the alias at all but always the real column name. Normally SQL doesn't allow you to refer to an alias in an ORDER BY clause, but MySQL does allow you to do that in the case where you are using ONLY the alias (not an operation on the alias) like in: select ccy, myval myval_old, sum(myval) as myval from mytable group by ccy order by myval desc; This is allowed just to make some of the most common ORDER BY clauses easy. The fact that you do: myval myval_old doesn't change the name of the column to myval_old, but just names the result of the column as 'myval_old'. You can still use myval in the ORDER BY and this will continue to refer to the original column
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.