I have a table with primary key in auto-increment column "id" and a column "data"
Contents of table:
id | data
1 | aaaaa
2 | bbbbb
3 | whatever :P
5 | dang
99 | hello
As you can see there are 5 rows. the id's are 1,2,3,5,99 (there are NO id = 4 or id = 6 to 98).
How can i export this table, and then import it in another table (same structure of course) and the id's will get the values 1,2,3,4,5 instead of 1,2,3,5,99.
(or import them in a table that has already data, and the imported ids will take whatever values are from that table's auto_increment value and go on?)
Note: If there is a solution specific for PhpMyAdmin its welcome.
-Sorry for bad english! (Ops Feel free to edit)
Create a table with the same layout. Then:
INSERT INTO new_table (data) SELECT data FROM old_table;
This will copy only the data fields into the new table. Since the id column is auto_increment, it will add ids counting from one upwards.
INSERT INTO newTable (data) SELECT data FROM oldTable;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With