PHP MySQL - ON DUPLICATE KEY UPDATE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there an easy way to overwrite a row (e.g. using replace) if a duplicate key already exists?

For instance, is there something like ON DUPLICATE KEY REPLACE (as opposed to UPDATE)?

Or do I have to:

key_exists = query database for key
if (key_exists){
    REPLACE...
}
else{
    INSERT...
}

Thank you!

Phillip

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux