Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么安全更新模式会阻止我使用在mysql的更新连接sql中包含关键列的where_Mysql - Fatal编程技术网

为什么安全更新模式会阻止我使用在mysql的更新连接sql中包含关键列的where

为什么安全更新模式会阻止我使用在mysql的更新连接sql中包含关键列的where,mysql,Mysql,我在mysql中运行更新连接sql,下面是我的sql UPDATE a JOIN b ON a.id = b.pid SET a.t = b.name WHERE a.id > 0 AND b.id > 0 然后我得到了一个错误: Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that use

我在mysql中运行更新连接sql,下面是我的sql

UPDATE a
        JOIN
    b ON a.id = b.pid 
SET 
    a.t = b.name
WHERE
    a.id > 0 AND b.id > 0
然后我得到了一个错误:

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 Editor and reconnect.

两个表中的id都是主键。我只是搞不懂为什么我要使用where,其中包括key列,mysql仍然阻止我。我知道关闭安全更新模式可以工作(但这不是一个好的做法),所以我想了解我的sql有什么问题,以及如何纠正它。我对原因很好奇。非常感谢。

也许优化器足够聪明,可以过滤掉这种情况。尝试
其中1=1
这似乎是某种维护查询(对吗?)只是暂时
设置sql\u safe\u updates=0
,执行更新,然后将其设置回1@juergend我试过了,但没用。@Cid是的,我知道,这让我困惑,所以我只想知道原因。为什么在使用where include主列时得到block