Bug #27537 Can not use variables as aliases / No puedo usar variables como alias
Submitted: 29 Mar 2007 20:36 Modified: 26 Apr 2007 18:33
Reporter: Luciano Fantuzzi Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version: 5.0.37-community-nt OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any
Tags: alias, user, variable

[29 Mar 2007 20:36] Luciano Fantuzzi
Description:
When I try to use a variable as an alias it results in error // Cuando intento usar una variable como alias me devuelve error.

How to repeat:
mysql> SET @a:="name";
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT "peter" AS @a FROM DUAL;

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 '@a FR
OM DUAL' at line 1
[26 Apr 2007 11:29] Valeriy Kravchuk
I think, you should just use prepared statements (http://dev.mysql.com/doc/refman/5.0/en/sqlps.html) in cases like this.
[26 Apr 2007 18:33] Luciano Fantuzzi
Yes, thanks.