Bug #68459 Error index out of range for column name alias in select statement
Submitted: 22 Feb 2013 4:32 Modified: 22 Feb 2013 6:25
Reporter: Bruno Braga Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.36 rev8542 OS:Linux
Assigned to: CPU Architecture:Any
Tags: column alias, DML, select syntax

[22 Feb 2013 4:32] Bruno Braga
Description:
The official documentation here: http://dev.mysql.com/doc/refman/5.5/en/select.html 
states that defining column name alias is optional, as well the [AS] syntax.

By querying using a select statement with column alias without the [AS] syntax, it returns the error: index out of range. Any manipulation with a column value (contact, substr, etc) then can be used without the [AS] syntax for alias.

The same behaviour can not be reproduced from command-line.

How to repeat:
Consider the following statements:

(1) select `table_name` a from `information_schema`.tables;

(2) select `table_name` as a from `information_schema`.tables;

(3) select concat(`table_name`, ' ') a from information_schema.tables;

The results from command line execution and Workbench's SQL Editor are as follows:

+--------------+-----+-----+-----+
|    ACTION    | (1) | (2) | (3) |
+--------------+-----+-----+-----+
| command line | OK  | OK  | OK  |
+--------------+-----+-----+-----+
|  SQL Editor  | NG  | OK  | OK  |
+--------------+-----+-----+-----+
[22 Feb 2013 6:25] MySQL Verification Team
Hello Bruno,

Thanks for your report.

Verified as reported on MySQL Workbench 5.2.36, but I can't reproduce your problem on MySQL Workbench 5.2.47.

Please could you try the latest MySQL Workbench 5.2.47?