Bug #5248 Syntax Error for correct Syntax in SELECT
Submitted: 27 Aug 2004 10:50 Modified: 27 Aug 2004 11:59
Reporter: Bernhard Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.3 OS:Linux (Linux Mandrake 10.1)
Assigned to: Sergei Golubchik CPU Architecture:Any

[27 Aug 2004 10:50] Bernhard
Description:
Using the star (*) wildcard as an entry in the list of queried columns produces a syntax error if it is not the first entry:

SELECT host, * FROM db
--> 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 db' at line 1
SELECT host, *, user FROM db
--> 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 '*, user FROM db' at line 1

The following quries work as expected:
SELECT * FROM db
SELECT *, host FROM db
SELECT host, db.* FROM db
SELECT host, db.*, user FROM db

How to repeat:
I tried on different databases and it always happend (as i expected since the error occures while parsing the query)
[27 Aug 2004 11:59] Sergei Golubchik
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

Additional info:

This is not a bug, syntax 'SELECT host, * FROM table' is illegal, according to the SQL standard:

<select list> ::=
    <asterisk>
  | <select sublist> [ { <comma> <select sublist> }... ]
<select sublist> ::=
    <derived column>
  | <qualified asterisk>