Error 1149: You have an error in your SQL syntax

You are viewing an old version of this article. View the current version here.
Error CodeSQLSTATEErrorDescription
114942000ER_SYNTAX_ERRORYou 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

This is one of the most common errors to see. It's caused by an SQL syntax error. The error message will give you a clue as to where the error could be, as MariaDB displays the text following where it picked up an error. There are a huge number of possible causes, but here are a few common ones;

Delimiters

Delimiters need to be present at the end of each statement. See 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;
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.