mysql错误1064更新,但查询看起来正确

rkttyhzu  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(332)

我不知道这是怎么回事

mysql> update messages set read=1 where id=4;
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 'read=1 where id=4' at line 1

mysql> show columns from messages;
+-------------------+---------------+------+-----+---------+----------------+
| Field             | Type          | Null | Key | Default | Extra          |
+-------------------+---------------+------+-----+---------+----------------+
| id                | int(11)       | NO   | PRI | NULL    | auto_increment |
| account_id        | varchar(255)  | NO   |     | NULL    |                |
| subject           | varchar(2048) | NO   |     | NULL    |                |
| message           | text          | NO   |     | NULL    |                |
| message_id        | int(11)       | NO   |     | 0       |                |
| read              | int(11)       | NO   |     | 0       |                |
| replied           | int(11)       | NO   |     | 0       |                |
| priority          | int(11)       | NO   |     | 0       |                |
| topic             | int(11)       | NO   |     | 0       |                |
| user_deleted      | int(11)       | NO   |     | 0       |                |
| created           | datetime      | NO   |     | NULL    |                |
| modified          | datetime      | NO   |     | NULL    |                |
| to_user_id        | int(11)       | NO   |     | 0       |                |
| recipient_deleted | int(11)       | NO   |     | 0       |                |
| recipient_read    | int(11)       | NO   |     | 0       |                |
+-------------------+---------------+------+-----+---------+----------------+
15 rows in set (0.00 sec)

关于如何更新messages表的read列,有什么想法吗?

dhxwm5r4

dhxwm5r41#

你可以在下面试试-你需要使用back-tick``作为reserve关键字

update messages set `read`=1 where id=4;

相关问题