0

我的 SQL 代码有一个小问题:

UPDATE articles SET like=like+1 WHERE id=1

当我试图在 PhpMyAdmin 中执行它时,我收到了这个错误:

#1064 - 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 'like=like+1 WHERE id=1' at line 1

像 int 的列默认设置为 0(长度为 11)。有谁知道我该如何修复它?请帮忙。

4

3 回答 3

5

LIKE is a keyword and cannot be used as a column name. You could change it (in your query) to `like`=`like`+1 (with backticks), but that's hardly solving the problem.

Rename your column.

于 2012-07-11T09:03:05.047 回答
4

引用您的字段名称:

UPDATE `articles` SET `like` = `like`+1 WHERE `id` = 1;
于 2012-07-11T09:02:51.557 回答
-1

您将字段“like”设置为与Sql的关键字LIKE相同,因此出现错误。只需更改字段的名称。

于 2012-07-11T09:14:18.693 回答