>>>>> "SH" == Scott Hess <scott@stripped> writes:
SH> As a backup for REPLACE in such cases, I use UPDATE, look at the affected
SH> rows value, and if no rows were affected, followup with INSERT (there's a
SH> race condition if someone else is in the same code - if the INSERT fails,
SH> try another UPDATE). This is tuned for cases where UPDATE is the norm,
If you try the INSERT first, then there's no race condition, provided
you have the necessary info to insert all the fields of the PRIMARY
KEY (or all UNIQUE keys). Other than that, you'll need to do a lock.
Personally, I find REPLACE useless unless you're inserting all the
fields.