List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 24 2000 12:43pm
Subject:Re: Duplicates in INSERT
View as plain text  
At 6:05 PM -0600 2000-02-23, Joey Mukherjee wrote:
>I have a text file which I parse in my program and then do the INSERT into the
>mysql database.
>I don't want duplicates in my database of course so my primary key 
>prevents that
>from happening.  However, I would like to know about the duplicate attempt.
>If I do an INSERT IGNORE, mysql_info never returns anything.  Leaving out the
>IGNORE, mysql will abort after the first duplicate.  If I do a 
>will abort after the first duplicate.  A DELAYED will let all the entries be
>inserted, but never return anything just like the INSERT IGNORE.
>Is there a way to find out when I am trying to add a duplicate, without having
>to query the database first?

Why don't you just use REPLACE and then (assuming no error occurred)
check the value of mysql_affected_rows()?

Paul DuBois, paul@stripped
Duplicates in INSERTJoey Mukherjee24 Feb
  • Re: Duplicates in INSERTJan Dvorak24 Feb
  • Re: Duplicates in INSERTPaul DuBois24 Feb