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