MySQL:更新UNIQUE键列的值而不重复行

时间:2014-12-02 12:07:14

标签: mysql

我正在尝试更新列的值,该列是三列UNIQUE KEY的一部分。 当我尝试更新此值时,MySQL不会抛出任何错误并重复行而不是更新它们。

id     | idpage | itemnature | itemindex | label | deleted
-------+--------+------------+-----------+-------+--------
208461 | 30331  |          4 |         1 |       |       0
208491 | 30331  |          4 |        11 |       |       0
208521 | 30331  |          4 |        21 |       |       0
208451 | 30331  |          6 |         1 |       |       0
208481 | 30331  |          6 |        11 |       |       0
208511 | 30331  |          6 |        21 |       |       0
208441 | 30331  |         10 |         1 |       |       0
208471 | 30331  |         10 |        11 |       |       0
208501 | 30331  |         10 |        21 |       |       0

enter image description here

这是我的查询无法正常工作:

UPDATE wcms.page_structure SET itemindex = 1 WHERE id = 208471;
UPDATE wcms.page_structure SET itemindex = 1 WHERE id = 208481;
UPDATE wcms.page_structure SET itemindex = 1 WHERE id = 208491;
UPDATE wcms.page_structure SET itemindex = 2 WHERE id = 208441;
UPDATE wcms.page_structure SET itemindex = 2 WHERE id = 208451;
UPDATE wcms.page_structure SET itemindex = 2 WHERE id = 208461;
UPDATE wcms.page_structure SET itemindex = 3 WHERE id = 208501;
UPDATE wcms.page_structure SET itemindex = 3 WHERE id = 208511;
UPDATE wcms.page_structure SET itemindex = 3 WHERE id = 208521;

当我这样做时,我得到超过9行!

感谢您的帮助。

0 个答案:

没有答案