I have some data which I want to add to an existing mysql database. The new data may have entries, which are already saved on DB. Since some of my columns are unique, I get, as expected, an ER_DUP_ENTRY error.
Bulk Insert
Let's say I want to use following statement to save "A", "B" and "C" in a column names
of table mytable
and "A" is already saved there.
insert into mytable (names) values ("A"), ("B"), ("C");
Is there a way to directly use bulk insert
to save "B" and "C" while ignoring "A"? Or do I have to build an insert
statement for every new row? This leads to another question:
Normalize Data
Should I assure not to upload duplicate entries before the actual insert
statement? In my case I would need to select
the data from database, eliminate duplicates and then perform the above seen insert
. Or is that a task which is supposed to be done by a database?