I didn't say it wouldn't. I was pointing out the danger of the method listed. Also, a danger with replace is that multiple records might be deleted for one insert if there are multiple unique keys in the table. Insert and replace statements will error out with the appropriate status.
Simon Green wrote:
Why would the REPLACE statement not work?
Simon (ps mite have missed some thing if so sorry)
-----Original Message----- From: gerald_clark [mailto:[EMAIL PROTECTED] Sent: 17 October 2003 14:08 To: Mike Knox Cc: '[EMAIL PROTECTED]' Subject: Re: Check for data before inserting
Mike Knox wrote:
Traditionally, I'd take the following approachYou have to lock the table first, or another user might insert the record between 1 and 2.
1) Update - assume it's there 2) If update fails (0 rows) do an insert
Thats assuming that the update case is more prevalent. If the row is unlikely to be there - insert and do the update if you get a duplicate key.
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]