Bug #47127 Inconsistent alias use with asterisk
Submitted: 4 Sep 2009 9:51 Modified: 19 Aug 2013 16:05
Reporter: Marc Nijland Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.0.85, 5.1.31, 5.1.37 OS:Linux
Assigned to: CPU Architecture:Any

[4 Sep 2009 9:51] Marc Nijland
Description:
I think the (required) use of an alias is inconsistent.

How to repeat:
-- success
select a, b from (select 1 a, 2 b) t;
select *, b from (select 1 a, 2 b) t;

-- error
select b, * from (select 1 a, 2 b) t;

-- fix with alias
select b, t.* from (select 1 a, 2 b) t;

Suggested fix:
The erroneous statement above should work
[4 Sep 2009 10:09] Valeriy Kravchuk
Thank you for the bug report. Verified just as described:

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

mysql>
mysql> -- error
mysql> select b, * from (select 1 a, 2 b) t;
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 '* fro
m (select 1 a, 2 b) t' at line 1
mysql>
mysql> -- fix with alias
mysql> select b, t.* from (select 1 a, 2 b) t;
+---+---+---+
| b | a | b |
+---+---+---+
| 2 | 1 | 2 |
+---+---+---+
1 row in set (0.00 sec)
[4 Sep 2009 11:42] Peter Laursen
I believe I have posted a similar report before.
[4 Sep 2009 13:27] Valeriy Kravchuk
Peter,

Quite possible that you reported this. But I can not find your report, sorry. Any hints are welcomed.
[4 Sep 2009 13:33] Peter Laursen
@Valeriy .. I cannot find either! So this may have been a 'side remark' in another report. 

I only remember that it was Sveta who was the support person and she advised the workaround to use an alias. I also do not remember the status/classsification of this one.

It is not important either of course who reported. Now it is here!
[19 Aug 2013 16:05] Gleb Shchepa
This bug is a duplicate of the bug#41235.
[19 Aug 2013 16:06] Gleb Shchepa
Also see the bug#57821 (another duplicate).