Linked Questions
15 questions linked to/from On duplicate key ignore?
975 votes
12 answers
1.2m views
"INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE"
While executing an INSERT statement with many rows, I want to skip duplicate entries that would otherwise cause failure. After some research, my options appear to be the use of either: ON DUPLICATE ...
0 votes
1 answer
3k views
Error while importing a database in MySQL Workbench [duplicate]
I did a backup file for an existing database and when I want to import this file to a new database I'm getting this error and the import process is stopped: ERROR 1062 (23000) at line 38: Duplicate ...
1103 votes
12 answers
1.2m views
How can I do 'insert if not exists' in MySQL?
I started by googling and found the article How to write INSERT if NOT EXISTS queries in standard SQL which talks about mutex tables. I have a table with ~14 million records. If I want to add more ...
16 votes
3 answers
12k views
"Insert ignore" vs "select and insert"
I want to write a program add new item to table. This item has an unique key name and it can be created by one of 100 threads, so I need to make sure that it is inserted only once. I have two ideas: ...
10 votes
5 answers
2k views
Is inserting a new database entry faster than checking if the entry exists first?
I was once told that it is faster to just run an insert and let the insert fail than to check if a database entry exists and then inserting if it is missing. I was also told that that most databases ...
6 votes
4 answers
2k views
MySQL multiple insert when duplicates not allowed.
I have a table with 3 columns. Each has a unique index. I'd like to do multiple inserts at once (300 records a pop). When a duplicate entry occurs it cancels the insert in its entirety. This means ...
2 votes
2 answers
3k views
MySQL Alternative to "Lock Table" in Stored Procedure
I have a requirement to insert a row into a table if a row does not already exist, and I need to do this using a stored procedure. I therefore need to select to check if the row already exists, ...
2 votes
1 answer
2k views
Jooq - Ignore Duplicates
I'm currently using Jooq for a project, but I need a way to ignore duplicate keys on insert. I've got an array of objects I want to write into a table but if they already exist determined by a ...
0 votes
1 answer
2k views
magento SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '606078' for key 'PRIMARY
I am working on a live site http://spectnlens.com/. so when I tack backup and unzip files on my localhost i get one error There has been an error processing your request SQLSTATE[23000]: Integrity ...
0 votes
1 answer
770 views
How to get the number of rows affected by INSERT ON DUPLICATE using PDO?
Using PHP's PDO with a MySQL database, how do I get the number rows affected by an INSERT ... ON DUPLICATE KEY UPDATE ... statement? For instance, how would it be done with the following query? ...
0 votes
1 answer
605 views
PHP INSERT ON DUPLICATE KEY IGNORE adding null values?
i am using the following code to update a database from an xml file, everything works as intended but now i have to add 2x more fields to the table and update the data manually via a html form. when ...
1 vote
2 answers
276 views
Inserting external data in database
I have to import some data in my database . And there are some record already exist in table, not all. So what I want to do that: Run a php script for inserting data in table from input array Make ...
0 votes
2 answers
466 views
MySQL time series database, track quantity/price/data history — insert a new row only if a new value is different from the previous one?
I am trying to do time series product database that tracks a product stock quantities (100k+ products). It will be updated from a CSV file every 30 min and I only want to insert a new record if the ...
0 votes
2 answers
280 views
Array Comparison and inserting unique value in PHP MySQL
I Have an array with all the id's in my MySQL DB. In second array, have ID's which I need to insert into the same table. I need to check if the Id's which I am going to insert are present in first ...
1 vote
1 answer
237 views
Best way to synchronize a list with a database
I have a list I need to synchronize with a MySQL database. Here's an example procedure: I have a table with metadata: +-------+ | value | +-------+ | test | | val | | smtn | | foo | +-------+ ...