为什么我不能根据不是主键的条件来更新列。
我正在尝试更新名称与特定条件匹配的选区表,如下所示,但以下查询显示错误Error code 1064, SQL state 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 'table constituencies set city_id = '1' where constituencies.name = "East Delhi"' at line 1
update table constituencies set city_id = '1' where constituencies.name = "East Delhi";update table constituencies set city_id = '1' where constituencies.name = "South Delhi";update table constituencies set city_id = '1' where constituencies.name = "Delhi Sadar";update table constituencies set city_id = '1' where constituencies.name = "Karol Bagh";update table constituencies set city_id = '1' where constituencies.name = "New Delhi";update table constituencies set city_id = '1' where constituencies.name = "Outer Delhi";update table constituencies set city_id = '1' where constituencies.name = "North East Delhi";update table constituencies set city_id = '1' where constituencies.name = "North West Delhi";update table constituencies set city_id = '1' where constituencies.name = "West Delhi";
是否有必要仅使用主键检查条件?
请在上面说明一下。
最佳答案
尝试
update constituencies set city_id = 1 where constituencies.name = "East Delhi";
您无需在mysql查询中编写Table。
关于sql - 为什么我不能根据不是主键的条件来更新列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2856450/