You have an error in your SQL syntax
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.
- 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
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 );
expected output
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 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 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.
✕ Concatenate user input directly into SQL strings
String interpolation is the primary vector for SQL injection attacks and also produces 1064 when user input contains quotes or special characters.
Window functions introduced. Syntax errors in window function clauses produce 1064 with context pointing inside the OVER() clause.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev