ahk2chan

MySQL Function Does Not Exist Error

MySQL Function Does Not Exist Error

I tried to execute a query for MySQL database and kept getting this error:
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 table1' at line 1

And the query is extremely simple as follow:

select count (*) from table1;

It is getting so frustrating and unbelievable… so I googled (hahaha)… well I did found out the solution… It is complaining the space between “count” and “(”!!! WHAT the hack (sorry I borrowed the phase from Rachel)? Once I removed the space the query runs!

select count(*) from table1;

Here is the “explaination” from MySQL:

By default, there must be no whitespace between a function name and the parenthesis following it. This helps the MySQL parser distinguish between function calls and references to tables or columns that happen to have the same name as a function. However, spaces around function arguments are permitted.”

“You can tell the MySQL server to accept spaces after function names by starting it with the –sql-mode=IGNORE_SPACE option.”

Unbelievable!!!! By the way, there is also another variation of the error message:

ERROR 1305 (42000): FUNCTION sampledb.COUNT does not exist

Oh well…

Filed under: Technical
  — 11:27 pm on Wednesday, September 26, 2007

del.icio.usdigg-ittechnoratigoogle bookmark

- RSS feed for comments on this post. - TrackBack URI

1 Comment »

Comment by Alex

April 1, 2010 @ 3:27 pm

Thanks, that was right on.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>