Bug #57821 select columnname,* from tablename failes
Submitted: 28 Oct 2010 18:12 Modified: 19 Aug 2013 15:10
Reporter: Darren Cassar Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.1+ OS:Any
Assigned to: CPU Architecture:Any

[28 Oct 2010 18:12] Darren Cassar
Description:
create table t1 (a int, b char);
insert into t1 values (1,'a');

select b,* from t1; (fails miserably)

select * from t1; (works fine)
select *,b from t1; (works fine)
select b,t1.* from t1; (works fine)

The reason why a command like that is helpful is with tables containing unhealthy number of rows and developer is trying to quicker view of certain columns. 

How to repeat:
as above

Suggested fix:
make select b,* from t1; work
[28 Oct 2010 18:22] Valeriy Kravchuk
This is easy to verify:

macbook-pro:5.5 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.7-rc-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create table t1 (a int, b char);
Query OK, 0 rows affected (0.07 sec)

mysql> insert into t1 values (1,'a');
Query OK, 1 row affected (0.00 sec)

mysql> select b,* from t1;
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 '* from t1' at line 1
mysql> select b, t1.* from t1;
+------+------+------+
| b    | a    | b    |
+------+------+------+
| a    |    1 | a    |
+------+------+------+
1 row in set (0.00 sec)

mysql> select *,b from t1;
+------+------+------+
| a    | b    | b    |
+------+------+------+
|    1 | a    | a    |
+------+------+------+
1 row in set (0.00 sec)

But this is also documented at http://dev.mysql.com/doc/refman/5.1/en/select.html:

"Use of an unqualified * with other items in the select list may produce a parse error. To avoid this problem, use a qualified tbl_name.*  reference"

So, I'd say we have a feature request here.
[19 Aug 2013 15:10] Gleb Shchepa
This bug is a duplicate of the bug#47127.
[19 Aug 2013 16:08] Gleb Shchepa
Also see the bug# #41235 (another duplicate).