List:General Discussion« Previous MessageNext Message »
From:Michael Stassen Date:May 18 2006 2:15pm
Subject:Re: Baffled by query error syntax
View as plain text  
sheeri kritzer wrote:
<snip>
> 
> MySQL usually gives a syntax error *where* the error happens.  In this
> case, it would indicate a problem with "SEC_TO_TIME(" but there
> shouldn't be a problem, both according to the manual AND according to
> my example.

The parser reads the query left-to-right and always quotes the first thing it 
doesn't understand.  As often as not, that's the first thing *after* the actual 
error.  Here's a simple example:

   SELECT version ();

"SELECT" is proper, of course.  Next comes "version".  It doesn't have a 
parenthesis attached, so it must be a column name.  Since "version" is a column, 
it should be followed by a comma, an alias, the word "AS", or some operator.  In 
that context, the "(" that comes next doesn't make sense, so that is what mysql 
tells you:

   mysql> SELECT VERSION ();
   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
   '()' at line 1

The actual error, though, is the space right before the quoted part of the query.

Michael
Thread
Baffled by query error syntaxMike Blezien17 May
  • Re: Baffled by query error syntaxsheeri kritzer17 May
    • Re: Baffled by query error syntaxMichael Stassen18 May
  • Re: Baffled by query error syntaxMike Blezien17 May
  • Re: Baffled by query error syntaxMichael Stassen18 May