Forum Moderators: coopster
I ran this mysql statement:
mysql> update phpbb_posts_text, phpbb_posts set phpbb_posts_text.post_id = phpbb_posts.x where phpbb_posts_text.post_id = phpbb_posts.post_id;
But I got this error:
ERROR 1062 (23000): Duplicate entry '2717' for key 1
I just need to know if this statement made any PARTIAL changes to my database, but then stops abruptly when it finds an error. this in effect would make me have to recover my db from a backup.
CREATE TABLE t1 (tid SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL);
INSERT INTO t1 VALUES(NULL), (NULL), (NULL), (5), (7), (9);
SELECT * FROM t1;
+-----+
¦ tid ¦
+-----+
¦ 1 ¦
¦ 2 ¦
¦ 3 ¦
¦ 5 ¦
¦ 7 ¦
¦ 9 ¦
+-----+
UPDATE t1 SET tid = tid + 1 ORDER BY tid DESC;
SELECT * FROM t1;
+-----+
¦ tid ¦
+-----+
¦ 2 ¦
¦ 3 ¦
¦ 4 ¦
¦ 6 ¦
¦ 8 ¦
¦ 10 ¦
+-----+
UPDATE t1 SET tid = tid - 1 ORDER BY tid DESC;
ERROR 1062 (23000): Duplicate entry '3' for key 1
SELECT * FROM t1;
+-----+
¦ tid ¦
+-----+
¦ 2 ¦
¦ 3 ¦
¦ 4 ¦
¦ 5 ¦
¦ 7 ¦
¦ 9 ¦
+-----+