On Mon,  4 Feb 2002 at 13:10:29 -0500, Erik Price wrote:

[ snip background ]

> I am sure that many people have done this sort of setup.  But what do 
> you do to get around the problem of INSERTing a pair of values that 
> already exist?  Because the combinations in "owners_objects" are UNIQUE 
> (the UNIQUE indexes), MySQL won't accept a pair that is already 
> present.  I see two possible options:
> 
> 1) Check to see if the combination is already present, and if so, do not 
> run the INSERT query
> 2) run the INSERT query regardless and suppress the error message
> 
> The disadvantage of the first one is that it adds an extra SQL query to 
> the process.  The disadvantage of the second one is that I think it is 
> somewhat tasteless to execute code that will knowingly error -- or 
> should I just stop trying to be such a perfectionist?

You can use REPLACE instead of INSERT -- see the manual entry: 

  
<URL:http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#REPLACE>

Cheers!

-- Marcus

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to