How to fix ERROR 1064: Syntax error near in MySQL

MySQLBEGINNERHIGHUpdated Dec 22, 2025· 177 views

MySQL error 1064 indicates a syntax error in your SQL query. This happens when MySQL encounters mistyped commands, reserved words used as identifiers, incorrect punctuation, or deprecated syntax that it cannot parse.

Quick fix

Fixes 1064

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 '<problem area>' at line X
  1. Read the error message carefully
  2. Check for typos in SQL keywords
  3. Wrap reserved words in backticks
  4. Verify parentheses, quotes, and punctuation
mysql — error
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 '<problem area>' at line X
ERROR 1064: Syntax error near

What this error means

MySQL error 1064 (ER_PARSE_ERROR) is thrown when the MySQL parser encounters an SQL statement it cannot understand. This is not a runtime error—it occurs at the parsing stage before any query execution. The error means your SQL syntax violates MySQL rules or contains commands MySQL does not recognize. Common culprits include typos in keywords, reserved words used without backticks, missing or extra punctuation, and deprecated commands from older MySQL versions.

Typical symptoms

  • SQL queries fail immediately with "You have an error in your SQL syntax"
  • Error message includes the approximate location of the syntax error ("near...")
  • Same query works on different MySQL version but fails on yours
  • Database operations fail in your application code when executing prepared statements
  • Stored procedures or triggers cannot be created due to syntax errors

Common causes

  1. Typos or misspelled SQL keywords (e.g., SLECT instead of SELECT, INSRT instead of INSERT)
  2. Using MySQL reserved words as table or column names without backticks (e.g., `select` must be wrapped)
  3. Mismatched or missing parentheses, brackets, or quotes in the query
  4. Obsolete or deprecated syntax (e.g., TYPE=InnoDB instead of ENGINE=InnoDB in older MySQL versions)
  5. Missing required clauses or values in INSERT, UPDATE, or CREATE statements
  6. Incorrect use of quotes—using double or single quotes for identifiers instead of backticks
  7. Version-specific syntax differences when migrating between MySQL 5.7 and 8.0
  8. Extra or missing commas in column lists or function arguments

How to fix "ERROR 1064: Syntax error near"

1Read the error message carefully

MySQL provides helpful error output that includes the location of the syntax error. The message format is:

bash
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 '<problem area>' at line X

The text shown after "near" pinpoints the problematic area. Focus your search on that location and surrounding code.

2Check for typos in SQL keywords

Review your query for common misspellings:

sql
-- Wrong (typo)
SLECT * FROM users;

-- Correct
SELECT * FROM users;

Also verify keywords like INSERT, UPDATE, DELETE, WHERE, FROM, JOIN, GROUP BY, ORDER BY are spelled correctly.

3Wrap reserved words in backticks

If you use MySQL reserved words (SELECT, FROM, WHERE, ORDER, GROUP, etc.) as table or column names, wrap them in backticks:

sql
-- Wrong (reserved word without backticks)
SELECT order FROM products;

-- Correct
SELECT `order` FROM products;

Do NOT use single (') or double (") quotes for identifiers—those are for string literals only.

4Verify parentheses, quotes, and punctuation

Check that:
- All opening parentheses have matching closing ones
- String values are enclosed in single quotes (e.g., 'John')
- Column lists have commas between items
- All semicolons are at the end of complete statements

sql
-- Wrong (missing closing parenthesis)
SELECT * FROM users WHERE id IN (1, 2, 3;

-- Correct
SELECT * FROM users WHERE id IN (1, 2, 3);

-- Wrong (unquoted string)
SELECT * FROM users WHERE name = John;

-- Correct
SELECT * FROM users WHERE name = 'John';
5Replace deprecated MySQL syntax

If migrating from MySQL 5.0 or earlier, update deprecated commands:

sql
-- Old (deprecated in MySQL 4.1, removed in 5.1)
CREATE TABLE users (id INT) TYPE=InnoDB;

-- New
CREATE TABLE users (id INT) ENGINE=InnoDB;

Check the MySQL Reference Manual for your version to identify deprecated features.

6Use MySQL Workbench or SQL editor with syntax highlighting

Tools like MySQL Workbench (official tool from MySQL) provide real-time syntax checking and highlighting. They catch 1064 errors before you execute:

- MySQL Workbench: Free, official, includes SQL editor with error highlighting
- SQL Fiddle: Web-based SQL testing tool
- Your IDE: Many code editors have SQL extensions with syntax validation

Copy your query into one of these tools to get instant feedback.

7Check MySQL version compatibility

Syntax varies between MySQL versions. Verify your MySQL version:

sql
SELECT VERSION();

Then check the MySQL Reference Manual for your version. Features added in MySQL 8.0 will not work on 5.7. If you're using syntax from a newer version on an older server, you'll see error 1064.

Advanced notes

In generated SQL (from ORMs, query builders, or templating), error 1064 often reveals issues in the generation logic. Check that your ORM is escaping identifiers correctly and using the right syntax for your MySQL version. For stored procedures and triggers, syntax errors prevent creation; validate the entire block before running. Character set and collation mismatches can sometimes appear as syntax errors in MySQL 5.7—ensure your connection charset matches the database.

Frequently asked questions

What does "1064" mean?
MySQL error 1064 (ER_PARSE_ERROR) is thrown when the MySQL parser encounters an SQL statement it cannot understand. This is not a runtime error—it occurs at the parsing stage before any query execution. The error means your SQL syntax violates MySQL rules or contains commands MySQL does not recognize.
How do I fix "1064"?
MySQL error 1064 indicates a syntax error in your SQL query. This happens when MySQL encounters mistyped commands, reserved words used as identifiers, incorrect punctuation, or deprecated syntax that it cannot parse.
What causes "1064"?
Typos or misspelled SQL keywords (e.g., SLECT instead of SELECT, INSRT instead of INSERT) Using MySQL reserved words as table or column names without backticks (e.g., select must be wrapped) Mismatched or missing parentheses, brackets, or quotes in the query
Is the "1064" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading