1

I have an issue while executing UPDATE statement.

UPDATE vehicles2 SET limit = @newlimit WHERE model = @vehiclenew

Error:

ER_PARSE_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 near 'limit = 1 WHERE model = 'crf450r'' at line 1

Can anyone help me please?

S.Malka
  • 11
  • 2

3 Answers3

2

LIMIT is a reserved MariaDB/MySQL keyword, and so if your vehicles2 table really has a column with this name, you will have to escape it with backticks:

UPDATE vehicles2
SET `limit` = @newlimit
WHERE model = @vehiclenew;

The best fix here is to actually not call your columns/tables/etc. using a keyword. Change limit to something else.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
1

Limit is a reserved keyword used to restrict the number of records to be returned in a query. If you have a column called LIMIT in your table, or any other name that matches a keyword for that matter, you have to use qualifiers around your column name so the database engine knows it is actually a column name and not a keyword. Wrap your column name around backtick and it should work.

UPDATE vehicles2 SET `limit` = @newlimit WHERE `model` = @vehiclenew
Jose Bagatelli
  • 1,367
  • 1
  • 15
  • 32
0

Please try below code and let me know ,if still there is any issue.

DECLARE @newlimit INT,
@vehiclenew VARCHAR(100)
SET @newlimit= put your values here ,
@vehiclenew='put Your values'
UPDATE vehicles2
SET `limit` = @newlimit
WHERE `model` = @vehiclenew
Ajeet Verma
  • 1,021
  • 1
  • 7
  • 25