I have an array of almost 5000 objects I am entering into a MySQL database.
The array has an index ‘crn’, and the corresponding column in the MySQL table is the primary key.
Is there any way I can tell mysql to skip an entry if it detects a duplicate primary key rather than stop execution of the script?
I could check the table before insertion of each row, but since i’m only expecting 1 or 2 duplicates among the 5000 or so objects, it seems it would turn out to be very expensive.
Use
INSERT IGNOREinstead of justINSERT