MySQL FAQs
FAQs Categories
Client Server Commands
Database Structure
Table Types or Storage Engines
Indexes
SQL Statements
Table Joins
Funtions and Operators
Tricky Select Queries
Speed Up Queries
Data Back Up
General Questions
Errors
1PLs Company - #1Payday.Loans Agency - Loans online and near me $100-$2500 (Same Day)
Powered by MySQL
 
Home / Errors / Question No: 51

ERROR 1064 (42000): You have an error in your SQL syntax

I try to run the following query.
INSERT INTO sections (order,edit,remove,section,type) 
VALUES('blah','blah','blah','blah','blah');
In response I got the the message:

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 'order,edit,remove,section,type) VALUES('blah','blah','blah','blah','blah')' at line 1.

Any idea to fix ERROR 1064 (42000): You have an error in your SQL syntax;?

Answer No: 51

Your above query contains reserved words in it those are causing error 1064 (42000). ORDER is a reserved word in MySQL and in standard SQL as well. If the column name in the table is ORDER, then put backquotes (`) around the word ORDER when using it as a column name. For Example:
INSERT INTO sections (`order`,edit,remove,section,type) 
VALUES('blah','blah','blah','blah','blah');
Best practice: Don't use reserved words for object (table, column,) or to use backquotes beside every column you used like:
INSERT INTO sections (`order`,`edit`,`remove`,`section`,`type`) 
VALUES('blah','blah','blah','blah','blah');

Related MySQL FAQs to the Above FAQ

Why-I-see-an-error-when-I-EXPLAIN-for-update-query Why I see an error when I EXPLAIN for update query?

ERROR-1295-(HY000):-This-command-is-not-supported-in-the-prepared-statement-protocol-yet ERROR 1295 (HY000): This command is not supported in the prepared statement protocol yet

1264-Out-of-range-value-adjusted-for-column 1264 Out of range value adjusted for column

1048-Column-cannot-be-null 1048 Column cannot be null

1093-You-can-not-specify-target-table-comments-for-update-in-FROM-clause 1093 You can not specify target table comments for update in FROM clause

1191-Cant-find-FULLTEXT-index-matching-the-column-list 1191-Cant find FULLTEXT index matching the column list

About FAQs: Recently Added FAQs

About MySQL FAQs: Site Map | Bookmark Us | Recommend this Site to Your Friend | Contact Us

Useful Links: Wikipedia.org | Oracle.com | w3schools.com | www.php.net | Github.com

© 2024  www.mysqlfaqs.net
All rights reserved.