PHP MySQL - ON DUPLICATE KEY UPDATE

PHP MySQL - ON DUPLICATE KEY UPDATE

am 19.06.2007 16:58:01 von Phillip Terry

------=_NextPart_000_01AB_01C7B258.525F1E20
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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 =3D query database for key
if (key_exists){
REPLACE...
}
else{
INSERT...
}

Thank you!

Phillip
------=_NextPart_000_01AB_01C7B258.525F1E20--

Re: PHP MySQL - ON DUPLICATE KEY UPDATE

am 19.06.2007 17:12:06 von Niel Archer

Hi

REPLACE [LOW_PRIORITY | DELAYED]
[INTO] tbl_name [(col_name,...)]
VALUES ({expr | DEFAULT},...),(...),...

Or:

REPLACE [LOW_PRIORITY | DELAYED]
[INTO] tbl_name
SET col_name={expr | DEFAULT}, ...

Or:

REPLACE [LOW_PRIORITY | DELAYED]
[INTO] tbl_name [(col_name,...)]
SELECT ...



Niel

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php