Bug #14772 select (*) syntax error
Submitted: 8 Nov 2005 21:48 Modified: 8 Nov 2005 22:10
Reporter: Andrea Rui Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.2600 OS:Windows (Win XP SP2)
Assigned to: MySQL Verification Team CPU Architecture:Any

[8 Nov 2005 21:48] Andrea Rui
Description:
the statement
      select count(*) from table;
works fine, but if you leave a space between the count keyword and the (*) raises an error.

Maybe it is not an error in mySQL, but any other RDBMS ignores blanks between different syntactic elements in the language.

How to repeat:
------------------
GOOD STATEMENT
------------------

mysql> select count(*) from dual;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

----------------
BAD STATEMENT
----------------

mysql> select count (*) 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 '*) from dual' at line 1
mysql>
[8 Nov 2005 22:10] MySQL Verification Team
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:

c:\mysql\bin>mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.16-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select count(*) from dual;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.08 sec)

mysql> set @@sql_mode='IGNORE_SPACE';
Query OK, 0 rows affected (0.00 sec)

mysql> select count (*) from dual;
+-----------+
| count (*) |
+-----------+
|         0 |
+-----------+
1 row in set (0.00 sec)

mysql> set @@sql_mode=""
    -> ;
Query OK, 0 rows affected (0.00 sec)

mysql> select count (*) 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 '*) from dual' at line 1
mysql>