duplicate record notification

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lipun4u
Forum Commoner
Posts: 82
Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:

duplicate record notification

Post by lipun4u »

In my database, after insertion of records, I want to know if the record inserted is duplicate or not. How can I do this ??
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: duplicate record notification

Post by markusn00b »

lipun4u wrote:In my database, after insertion of records, I want to know if the record inserted is duplicate or not. How can I do this ??
Do a search on the database and compare the values.

Code: Select all

 
SELECT `id` FROM `db_name`.`tbl_to_srch` WHERE `some_clmn` = '$text';
 
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: duplicate record notification

Post by califdon »

lipun4u wrote:In my database, after insertion of records, I want to know if the record inserted is duplicate or not. How can I do this ??
It seems to me you should want to check for possible duplicate before inserting a new record. In any case, what do you mean by "duplicate"? Duplicate ID number? Duplicate Name? Completely identical record? If it's a duplicate ID number, you should be using a primary key, which will reject any attempt to insert a duplicate key.
Post Reply