List:General Discussion« Previous MessageNext Message »
From:Jeremiah Gowdy Date:December 28 2005 4:47pm
Subject:Re: update or insert if necessary?
View as plain text  
Actually, you may be more interested in:

INSERT . ON DUPLICATE KEY UPDATE

----- Original Message ----- 
From: "steve" <networks1@stripped>
To: <mysql@stripped>
Sent: Wednesday, December 28, 2005 6:57 AM
Subject: update or insert if necessary?


I have a situation where I need to update a record for a given key in a 
MySQL table, but insert a record if the key doesn't exist.  I could do this 
by doing a SELECT on the key, then doing an UPDATE if anything comes back, 
or and INSERT otherwise.  This seems rather clunky though, and I'm wondering 
if there is anything like and "up-sert" command, or at least a preferred way 
of doing this operation.

TIA....Steve

Thread
update or insert if necessary?steve28 Dec
  • Re: update or insert if necessary?Jeremiah Gowdy28 Dec
  • Re: update or insert if necessary?Jeremiah Gowdy28 Dec
RE: update or insert if necessary?John Trammell28 Dec