You don't have to use backticks for strings but quotes while right
is a reserved keyoword and it needs to be surrounded with backticks
UPDATE users SET `right` = 'administrator' WHERE id = 3;
Question
I'm using Ubuntu 13 and i've installed mysql2 for my rails server.
In mysql console (mysql -p
) i'm trying to change record value. My database called daysandnights, I got tables users with different fields.
use daysandnights
UPDATE users SET right = `administrator` WHERE id = 3;
And i got: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'right =
administratorWHERE id = 3' at line 1
I know there are lots of such questions, but... What's the trick?
Solution
You don't have to use backticks for strings but quotes while right
is a reserved keyoword and it needs to be surrounded with backticks
UPDATE users SET `right` = 'administrator' WHERE id = 3;