List:General Discussion« Previous MessageNext Message »
From:Michael Stassen Date:December 14 2005 1:21am
Subject:Re: bug in MySQL 5?
View as plain text  
Octavian Rasnita wrote:
> From: "Gleb Paharenko" <gleb.paharenko@stripped>
> 
>>Hello.
>>
>>In my opinion, it is not a bug. REPLACE has returned the sum
>>of affected rows - one was deleted, and one was inserted. See:
>>  http://dev.mysql.com/doc/refman/5.1/en/replace.html
> 
> Thank you. I have seen that's the true.
> Is there any MySQL command that instead of 
> 
> if(record exists) {
> delete line
> insert new line
> }
> else {
> insert line
> }
> 
> does something like:
> 
> if (record exists) {
> update record with the specified fields
> }
> else {
> insert record
> }
> 
> Thank you.
> 
> Teddy

Yes.  You want SELECT ... ON DUPLICATE KEY UPDATE ...  See the manual for 
details <http://dev.mysql.com/doc/refman/5.0/en/insert.html>.

Michael


Thread
bug in MySQL 5?Octavian Rasnita13 Dec
  • Re: bug in MySQL 5?Gleb Paharenko13 Dec
  • Re: bug in MySQL 5?Octavian Rasnita13 Dec
    • Re: bug in MySQL 5?Michael Stassen14 Dec