lipun4u Posted October 22, 2009 Share Posted October 22, 2009 In my database, after insertion of records, I want to know if the record inserted is duplicate or not. How can I do this ?? Quote Link to comment https://forums.phpfreaks.com/topic/178632-duplicate-record-notification/ Share on other sites More sharing options...
Daniel0 Posted October 22, 2009 Share Posted October 22, 2009 Why not just check if it exists before inserting? Quote Link to comment https://forums.phpfreaks.com/topic/178632-duplicate-record-notification/#findComment-942198 Share on other sites More sharing options...
lipun4u Posted October 22, 2009 Author Share Posted October 22, 2009 that will be time consuming. it returns 1062 error code(in my case....) is this the universal error code for duplicate record insertion ?? Quote Link to comment https://forums.phpfreaks.com/topic/178632-duplicate-record-notification/#findComment-942200 Share on other sites More sharing options...
Daniel0 Posted October 22, 2009 Share Posted October 22, 2009 Yes, that error code means what you're trying to insert is a duplicate on a row that's supposed to be unique. Quote Link to comment https://forums.phpfreaks.com/topic/178632-duplicate-record-notification/#findComment-942203 Share on other sites More sharing options...
nadeemshafi9 Posted October 22, 2009 Share Posted October 22, 2009 In my database, after insertion of records, I want to know if the record inserted is duplicate or not. How can I do this ?? something like this, i bet someone comes up with a better idea biut insert into .... $last_id = mysql_insert_id(); $sql = "select count(*) as count from blah b1 where name = (select name from blah b2 where id = {$last_id}) " Quote Link to comment https://forums.phpfreaks.com/topic/178632-duplicate-record-notification/#findComment-942206 Share on other sites More sharing options...
nadeemshafi9 Posted October 22, 2009 Share Posted October 22, 2009 Why not just check if it exists before inserting? lol, im getting there Quote Link to comment https://forums.phpfreaks.com/topic/178632-duplicate-record-notification/#findComment-942207 Share on other sites More sharing options...
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.