View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 08:13 AM
Captain Paralytic
 
Posts: n/a
Default Re: error when insert an already existing entry


Dennis Kuntzemann wrote:
> Hello,
>
> when my application wants to insert a row which is already in the table
> there is an error message, ok.
> But how can I do it that the old one will be overwritten or nothing happens
> and the rest of the sql-statement is executed?
>
> at the moment my statement looks like this:
>
> insert into cbc_survey(ticketnr)
> (SELECT ticketno FROM ticket t,global g
> where state = 'xx'
> and ..);
>
> thank u very much.
>
> best regards,
>
> Dennis


REPLACE INTO will delete the old record and replace it with the new
one.
INSERT ... ON DUPLICATE KEY UPDATE will retain the original record and
update whatever fields you specify.

Reply With Quote