Sample Header Ad - 728x90

It's possible to skip duplicate keys (i.e. MERGE) in a BULK INSERT in MySQL?

1 vote
2 answers
6659 views
I have a INSERT...SELECT statement that I want to run several times from TABLE1 to TABLE2 as the data in TABLE1 will change overtime. I don't expect the past data from select to change overtime, the select will just return more new data, and the same old data of previous queries. But I cannot insert old data again because of the unique key constraint on the primary keys. What I would like to achieve is a kind of INSERT ...ON DUPLICATE KEY UPDATE... but for a INSERT...SELECT. Skipping the duplicate keys, will be enough, but I'm not sure how to do it
Asked by Glasnhost (478 rep)
Feb 24, 2020, 10:37 AM
Last activity: Feb 7, 2024, 08:02 AM