【问题标题】:MySQL Error 1064 with UPDATE, but query looks correctMySQL 更新时出现错误 1064,但查询看起来正确
【发布时间】:2019-05-06 19:34:48
【问题描述】:

我不知道这里发生了什么

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)

关于如何更新消息表的读取列的任何想法?

【问题讨论】:

  • 你会找到READhere。请注意,即使是 Stack Overflow 的语法高亮显示,该单词也会使用不同的颜色。

标签: mysql mysql-cli


【解决方案1】:

您可以在下面尝试 - 您需要使用反引号 `` 因为它是保留关键字

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

【讨论】:

  • @JeffreyL.Roberts,是的 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-18
  • 1970-01-01
  • 1970-01-01
  • 2018-04-18
  • 1970-01-01
  • 2017-01-07
  • 2021-11-02
相关资源
最近更新 更多