更新表而不打开安全模式

时间:2015-11-18 16:23:49

标签: mysql

我有以下表格:

A:
id | b_id | priority
1    1      1
2    1      2
3    2      1

B:
id
1
2

我想更新指定A的{​​{1}}表中的所有行 - 更具体地说,我想要交换b_id列中的值。

这就是我所拥有的:

priority

然而,它没有工作,我正在接受

UPDATE A a1
INNER JOIN A a2
ON (a1.priority, a2.priority) IN ((1,2),(2,1))
SET a1.priority = a2.priority
WHERE a1.id = (SELECT a3.id FROM A a3 WHERE b_id = 1);

错误。

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. 0.00033 sec 表在A列上有主键。 id表的外键Ab_id

出了什么问题?

0 个答案:

没有答案