On a bulk insert, how do I ignore a duplicate key update for primary key ‘id’ while only updating the entry for another key ‘another_unique_id’?
INSERT INTO
some_table (`id`, `another_unique_id`, `raw_data)
VALUES (5 , 'ABCDEFG', 'blah')
ON DUPLICATE KEY UPDATE ...?
For example –
If there’s a record with id: 5, I don’t want to update it. I’ll just insert a new record.
If there’s a record with ‘ABCDEFG’ in the ‘another_unique_id’ field, then I’d like to update that entry to ‘blah’
I think you should pass
otherwise it doesn’t make sense