更新查询失败,错误:1175 [英] Update query failing with error : 1175
问题描述
我正在尝试使用以下查询更新表
I am trying to update a table using the following query
update at_product A join
(
SELECT atbillfields.billeditemguid,count(*) AS numberOfPeopleBought
,sum(atbillfields.billeditemqty) AS soldquantity
FROM jtbillingtest.at_salesbill atsalesbill
JOIN jtbillingtest.at_billfields atbillfields
ON atsalesbill.billbatchguid=atbillfields.billbatchguid
WHERE atsalesbill.billcreationdate BETWEEN '2013-09-09' AND date_add('2013-09-09', INTERVAL 1 DAY)
GROUP BY atbillfields.billeditemguid) B ON B.billeditemguid = A.productguid
SET A.productQuantity = A.productQuantity - B.soldquantity
但是,出现以下异常:
错误代码:1175.您正在使用安全更新模式,并且试图 更新没有使用KEY列的WHERE的表以禁用安全 模式下,在首选项"->"SQL查询"中切换选项,然后重新连接.
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.
当我给where
子句进行像A.productQuantity = 1
这样的更新时,它会更新该特定内容.
When I gave a where
clause with the update like A.productQuantity = 1
, it updated that particular.
有人可以指出为什么我无法执行查询以及如何解决该问题吗?
Can someone point why I am unable to execute the query and how to solve the issue?
推荐答案
看看:
如果要在没有where键的情况下进行更新,则必须执行
If you want to update without a where key you must execute
SET SQL_SAFE_UPDATES=0;
在查询之前.
另一种选择是重写查询或包含一个键.
Another option is to rewrite your query o include a key.
这篇关于更新查询失败,错误:1175的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!