Rafael Rafael - 4 months ago 7
MySQL Question

Where is the error in that SQL query?

I'm unable to find the error in the syntax below, can someone please help me?

UPDATE release
SET title='lalala', content='blablablablablablalbsalball'
WHERE id=1


The table and columns names are correct. id 1 exists. I'm lost here.

Answer

release is a MySQL reserved keyword.

https://dev.mysql.com/doc/refman/5.0/en/keywords.html

UPDATE release SET title='lalala', content='blablablablablablalbsalball' WHERE id=1

Solutions:

1) Add backtick against release:

UPDATE `release` SET title='lalala',
content = 'blablablablablablalbsalball' WHERE id=1

2) Add database name before release

This way, MySQL will consider release as Database table name, not keyword.

UPDATE DB_NAME.release SET title = 'lalala',
content = 'blablablablablablalbsalball' WHERE id=1