Reputation: 35
I have two tables in my databaes: original_db and archive_db.
in original_db I have two cols:
in archive_db I have three cols:
I want to copy original_db to archive_db when user_id is let's say '1'
sql query:
INSERT INTO archive_db (user_id, name)
SELECT '1', name FROM original_db
After query this at first time everything is ok. So I Have archive_db:
but when I do again this query with another user_id let's say '2':
INSERT INTO archive_db (user_id, name)
SELECT '2', name FROM original_db
I get this archive_db table:
Why the id has the wrong autoincrementation, it should be 1,2,3,4,5,6
Upvotes: 0
Views: 62
Reputation: 95
And didn't 3 rows be deleted during the test? Then just set autoincrement: ALTER TABLE archive_db AUTO_INCREMENT = 4;
Upvotes: 1