Suvin Posted December 2, 2010 Report Share Posted December 2, 2010 Hi All, I am using MySql server as my backend for current project. I need to store around five records per second to my database. Is there any way to check for duplicate record present in the databse while inserting the data? Retrieving the complete data and checking it with current record is not a good solution all the time I guess. Thanks in advance, Suvin. Quote Link to comment
ShaunR Posted December 2, 2010 Report Share Posted December 2, 2010 Hi All, I am using MySql server as my backend for current project. I need to store around five records per second to my database. Is there any way to check for duplicate record present in the databse while inserting the data? Retrieving the complete data and checking it with current record is not a good solution all the time I guess. Thanks in advance, Suvin. You can use "REPLACE" which will "INSERT" if it doesn't exist or, "DELETE" the old record and then "INSERT" if it does. Quote Link to comment
Suvin Posted December 2, 2010 Author Report Share Posted December 2, 2010 Thanx a lot for the input Quote Link to comment
asbo Posted December 2, 2010 Report Share Posted December 2, 2010 If you don't want to update data, you could also use unique indexes across the columns that would define duplicates. Duplicate records would simply be dropped, so this is probably faster than a replace. There's also INSERT ... ON DUPLICATE if you only want to partially update a record if the record already exists. Quote Link to comment
jzoller Posted December 2, 2010 Report Share Posted December 2, 2010 Depending on your situation, you might also try "INSERT IGNORE INTO..." See http://stackoverflow...exists-in-mysql Joe Z. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.