好吧,我很难过这个:
mysql> INSERT INTO item (col1) VALUES ('testing') WHERE item_name = 'server1';
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 'WHERE item_name = 'server1'' at line 1
这是表desc(稍微消毒):
mysql> desc item;
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| item_name | varchar(128) | YES | | | |
| active | int(11) | NO | | 0 | |
| col1 | varchar(512) | YES | | NULL | |
+--------------+--------------+------+-----+---------+----------------+
我已经尝试过INSERT的一些变化,但我无处可去 . 期待有人揭露我所遗忘的任何明显的事情!
运行:mysql Ver 14.12 Distrib 5.0.95,对于使用readline 5.1的redhat-linux-gnu(x86_64)(我知道它已经老了,但我目前无法升级此框) .
2 回答
如果您要更新现有行,则为:
您没有正确使用
INSERT
语句,如果使用VALUES
子句,则无法对其应用WHERE
条件 .以下是具有相应语法的相同查询:
希望这会帮助你 .