这是我的桌子
+--------+--------------+--------------+------+
| I_Code | Name | Category | rate |
+--------+--------------+--------------+------+
| 1001 | Masala Dosa | South Indian | 60 |
| 1002 | Vada Sambhar | South Indian | 40 |
| 1003 | Idli | South Indian | 40 |
| 1004 | Chow Mein | Chinese | 80 |
| 2002 | Dimsum | Chinese | 60 |
+--------+--------------+--------------+------+而I_Code是主键。我想将周星驰的I_Code更改为2001年,我使用了以下代码
use food;
update table items
set I_Code = 2001
where name = "Chow Mein";但它总是犯这个错误
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 'table items set I_Code = 2001 where name = "Chow Mein"' at line 1出什么问题了,我怎么解决这个问题?
发布于 2022-02-03 13:41:55
你的语法错了!https://dev.mysql.com/doc/refman/8.0/en/update.html
这应该是可行的:
update items
set I_Code = 2001
where name = "Chow Mein";"update table (tablename)“不是syntaxt,而是"update (tablename)”
发布于 2022-02-03 13:48:10
使用以下语法:
UPDATE table_name SET col-name = value WHERE id = value你的答案:
UPDATE items SET I_Code = 2001 WHERE Name = 'Chow Mein';如果这不起作用,那就试试这个:
SET SQL_SAFE_UPDATES = 0;
UPDATE items SET I_Code = 2001 WHERE Name = 'Chow Mein';https://stackoverflow.com/questions/70972276
复制相似问题