2015-02-05 127 views
-2

我觉得应该有一些愚蠢的事,但I'm获得: Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect. 0.000 sec运行此查询时:MySQL错误1175当查询where子句

update cities 
set province_id = 1 
where name = 'Palma de Mallorca'; 
+0

你应该做什么错误信息说... – 2015-02-05 17:09:53

+0

在mysql工作台,首选项 - > SQL查询和禁用安全模式选项 – 2015-02-05 17:10:25

+1

'安全模式'可以避免您运行危险的查询,我认为你可以避免此警报添加“限制1”到字符串 – Olvathar 2015-02-05 17:11:55

回答

2

你并不需要禁用安全模式选项。只需执行您的查询并通过ID更新行而不是其他字段。即

update cities 
set province_id = 1 
where id = 45; 

如果你的mysql表没有ID字段。添加一个,使其自动递增并将其设置为主键。然后再次运行您的查询。

+0

你的回答是对的。不过,我需要按名称过滤。有什么办法吗?我应该禁用安全模式吗? – Rober 2015-02-05 17:20:25