> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/error-codes/mariadb-error-codes-1100-to-1199/e1149.md).

# Error 1149: You have an error in your SQL syntax

| Error Code | SQLSTATE | Error             | Description                                                                                                                        |
| ---------- | -------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| 1149       | 42000    | ER\_SYNTAX\_ERROR | You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use |

## Possible Causes and Solutions

A statement with a syntax error doesn't return this error code. The server returns [error 1064](/docs/server/reference/error-codes/mariadb-error-codes-1000-to-1099/e1064.md) instead, with this message followed by the part of the statement where parsing stopped, and its line number:

```
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 'SELEC 1' at line 1
```

The error code 1149 itself comes only from the [BINLOG](/docs/server/reference/sql-statements/administrative-sql-statements/binlog.md) statement, when its base64-encoded event data is empty or not valid. For example, this happens when you replay damaged or truncated [mariadb-binlog](/docs/server/clients-and-utilities/logging-tools/mariadb-binlog.md) output:

```
ERROR 1149 (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
```

The text after `near` is where the parser stopped. The mistake is usually there or just before it. Most syntax errors are typos, but here are a few common causes.

### Delimiters

Delimiters need to be present at the end of each statement. See [Delimiters](/docs/server/clients-and-utilities/mariadb-client/mariadb-command-line-client.md#delimiters). For example:

```
SELECT 1
SELECT 2;
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 'SELECT 2' at line 2
```

Here, there was no delimiter separating the first and the second line. MariaDB picked up the error at the start of the second line, pointing one to the end of the first line. The correct syntax is:

```
SELECT 1;
SELECT 2;
```

### Delimiters in Stored Programs

When creating [stored programs](/docs/server/server-usage/stored-routines.md) from the command-line, it is likely you will need to differentiate between the regular delimiter and a delimiter inside a [BEGIN END](/docs/server/reference/sql-statements/programmatic-compound-statements/begin-end.md) block. See [Delimiters](/docs/server/clients-and-utilities/mariadb-client/mariadb-command-line-client.md#delimiters).

For example, take the following, seemingly-valid declaration:

```
CREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC
BEGIN
  DECLARE x TINYINT;
  SET x = 42;
  RETURN x;
END;
```

Attempting to run will result in an error:

```
CREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC
    -> BEGIN
    ->   DECLARE x TINYINT;
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 '' at line 3
```

The error was picked up at the end of the `DECLARE x TINYINT;` line, guiding one to the delimiter found there. The solution is to specify a distinct delimiter for the duration of the process, using the DELIMITER command, for example:

```
DELIMITER //

CREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC
BEGIN
  DECLARE x TINYINT;
  SET x = 42;
  RETURN x;
END 

//

DELIMITER ;
```

### Reserved Words

[Reserved words](/docs/server/reference/sql-structure/sql-language-structure/reserved-words.md) cannot be used as [identifiers](/docs/server/reference/sql-structure/sql-language-structure/identifier-names.md) unless they are quoted. For example:

```
CREATE TABLE order(id INT);
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 'order(id INT)' at line 1
```

The error was picked up at the `order` identifier, leading one to suspect that it's causing the problem. And indeed, it's a [reserved word](/docs/server/reference/sql-structure/sql-language-structure/reserved-words.md). There are a number of possible solutions.

Use a new, non-reserved, identifier:

```
CREATE TABLE orders(id INT);
```

or quote the identifier:

```
CREATE TABLE `order`(id INT);
```

or [fully qualify](/docs/server/reference/sql-structure/sql-language-structure/identifier-qualifiers.md) the identifier:

```
CREATE TABLE test.order(id INT);
```

The list of reserved words changes between versions. For example, `ACCESSIBLE` was reserved before MariaDB 12.0, so `CREATE TABLE accessible(id INT)` fails on older versions and works on newer ones.

### Syntax Doesn't Match SQL\_MODE

Some syntax may be valid in a particular [SQL\_MODE](/docs/server/server-management/variables-and-modes/sql_mode.md), but not in others. There are too many to list here, but the [SQL\_MODE](/docs/server/server-management/variables-and-modes/sql_mode.md) page provides a full list. For example:

```
CREATE TABLE "t" (id INT);
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 '"t" (id INT)' at line 1
```

The error message directs one to the identifier `t`. Double quotes cannot be used to [quote identifiers](/docs/server/reference/sql-structure/sql-language-structure/identifier-names.md#quote-character) unless ANSI\_MODE is set, which in this case it isn't:

```
select @@sql_mode;
+-------------------------------------------------------------------------------------------+
| @@sql_mode                                                                                |
+-------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------+
```

Either quote with the standard quote character, the backtick, or set the appropriate SQL\_MODE:

```
SET @@SQL_MODE = CONCAT(@@SQL_MODE, ',ANSI_QUOTES');
CREATE TABLE "t" (id INT);
```

#### Oracle Mode

[Oracle mode](/docs/release-notes/community-server/about/compatibility-and-differences/sql_modeoracle.md) in particular has a large number of differences to the default [SQL\_MODE](/docs/server/server-management/variables-and-modes/sql_mode.md), for example:

```
CREATE TABLE t (id VARCHAR2(10));
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 '(10))' at line 1
```

The error is identified just after the VARCHAR2 type is specified, and this type is not valid in the default mode:

```
SELECT @@sql_mode;
+-------------------------------------------------------------------------------------------+
| @@sql_mode                                                                                |
+-------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------+
SET SQL_MODE='ORACLE';
CREATE TABLE t (id VARCHAR2(10));
```

See [SQL\_MODE=ORACLE](/docs/release-notes/community-server/about/compatibility-and-differences/sql_modeoracle.md) for a full list of syntax differences.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
