MySQL Error 1064 is a general parse error that the query parser encountered when processing the SQL statement before execution. This error is basically saying that you have some sort of syntax error in your SQL statement.
The MySQL server is very helpful and gives an error message of the following form:
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 %s at line %d.
In this case, %s would be the particular part of the query that the parser got stuck at, while %d tells what line in the SQL that the error occurs.
A number of things can be the source of a MySQL Error 1064. It could be a typographical error, incorrect keywords used, too many brackets or quotes, and those sorts of things.
To figure out the cause of the error, first read the actual error message closely to find the offending part of your SQL. Look there (and sometimes a bit to the left of where MySQL says the error is) to search for what the error might be. Look for typographical errors first. If there are none, look back on an example of the SQL command that you are trying to use to see why it works and yours doesn't.
Below we show examples of the kinds of things that can trigger a MySQL parse error.
Look at the following SQL statements which contain errors and the error messages which are generated as a result.
1) In this case, we have a typographical error:
CREATE DATABSAE sample;
MySQL is spot on, as it show us exactly the word that we have spelled incorrectly.
2) In this case, we are using a reserved word:
CREATE DATABASE select;
Once again, MySQL is spot on. Our command cannot work because we are attempting to create a table with the same name as a reserved word.
3) For the remainder of cases, it is best to compare the SQL you are trying to execute with an example of SQL that is known to work to see where you might have made an error. You can also consult a tutorial on the syntax of the particular statement for help.
We hope you found this tutorial on MySQL Error 1064 useful.