1064ERRORTier 1 — Safe✅ HIGH confidenceYou have an error in your SQL syntax
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
- 1Using a reserved word (e.g., ORDER, GROUP, SELECT) as a table or column name without backtick quoting
- 2Missing comma between column definitions in CREATE TABLE
- 3Using MySQL/MariaDB-specific syntax on a different database engine (or vice versa)
- 4A string literal is missing its closing quote
- 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.
CREATE TABLE orders (
id INT PRIMARY KEY,
order INT NOT NULL -- 'order' is a reserved word
);Fix 1: Quote reserved words with backticks
When a reserved word must be used as an identifier.
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.
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
🔗 Related errors
📄 Reference pages