1064ERRORTier 1 — Safe✅ HIGH confidence

You have an error in your SQL syntax

Category: Syntax ErrorVersions: All MariaDB / MySQL versions

What this means

Error 1064 (SQLSTATE 42000) is the generic SQL syntax error. It is returned when the parser cannot interpret the SQL statement. The error message includes the approximate position of the problem and a snippet of the offending text, but the actual mistake is often slightly before that position.

Why it happens

  1. 1Using a reserved word (e.g., ORDER, GROUP, SELECT) as a table or column name without backtick quoting
  2. 2Missing comma between column definitions in CREATE TABLE
  3. 3Using MySQL/MariaDB-specific syntax on a different database engine (or vice versa)
  4. 4A string literal is missing its closing quote
  5. 5Using a feature not available in the connected MariaDB version

How to reproduce

A reserved word is used as a column name without backtick quoting.

trigger — this will ERROR
CREATE TABLE orders (
  id INT PRIMARY KEY,
  order INT NOT NULL  -- 'order' is a reserved word
);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INT NOT NULL' at line 3

Fix 1: Quote reserved words with backticks

When a reserved word must be used as an identifier.

fix
CREATE TABLE orders (
  id INT PRIMARY KEY,
  `order` INT NOT NULL
);

Why this works

Backtick quoting (`identifier`) escapes any identifier including reserved words, allowing them to be used as column or table names. This is a MariaDB/MySQL extension; standard SQL uses double quotes.

Fix 2: Rename the identifier to a non-reserved word

When the schema is still being designed.

fix
CREATE TABLE orders (
  id INT PRIMARY KEY,
  order_num INT NOT NULL  -- renamed to non-reserved word
);

Why this works

Choosing non-reserved words for identifiers avoids quoting requirements and is more portable across database engines.

What not to do

Concatenate user input directly into SQL strings

Why it's wrong: String interpolation is the primary vector for SQL injection attacks and also produces 1064 when user input contains quotes or special characters.

Version notes

MariaDB 10.3+Window functions introduced. Syntax errors in window function clauses produce 1064 with context pointing inside the OVER() clause.

Sources

📚 Official docs: https://mariadb.com/kb/en/reserved-words/

🔧 Source ref: MariaDB Server error code 1064 / ER_PARSE_ERROR

📖 Further reading: MariaDB reserved words

Confidence assessment

✅ HIGH confidence

Stable. The parser error position reporting is consistent across versions.

See also

📄 Reference pages

MariaDB reserved wordsbacktick quoting
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →