Saturday, September 19, 2009

MySQL, Insert Statement "ERROR 1064 (42000): You have an error in your SQL syntax"

So, I got the error "ERROR 1064 (42000): You have an error in your SQL syntax" when trying to execute a similar insert statement to:

INSERT INTO sections (code, desc) VALUES('123','example of a description');

It was due to the 'desc' field being a reserved word. If you're getting a similar error, make sure that your field names are not using any reserved words in MySQL. Although, yes it is kind of strange that MySQL would allow you to create fields based on reserved words to begin with. To solve my problem, I used:

INSERT INTO sections (code, description) VALUES('123','example of a description');



No comments:

Post a Comment