mysql merge 2 tables,same structure, overlapping values in keys (auto_increment)
I have two tables, with the same structure, order_old and order_new. Key field on both is order_id which is auto_increment. order_old has 590 records in it, order_new has 100; I want to copy/add all the data from order_new into order_old, starting after the last record, but am not sure how to do this as the ordr_id keys in ord开发者_运维技巧er_new are lower than those in order_old
any advise would be appreciated!
David
If no other tables are related to the two, you can use:
INSERT INTO order_old
( field2 --- do not include the order_id
, field3
, ...
)
SELECT
field2 --- same here
, fields3
, ...
FROM order_new
For other options, check this similar question: how-can-i-merge-two-mysql-tables
精彩评论