List:General Discussion« Previous MessageNext Message »
From:John Trammell Date:December 28 2005 4:47pm
Subject:RE: update or insert if necessary?
View as plain text  
You should read
http://dev.mysql.com/doc/refman/4.1/en/insert.html 
and maybe
http://dev.mysql.com/doc/refman/4.1/en/replace.html

> -----Original Message-----
> From: steve [mailto:networks1@stripped] 
> Sent: Wednesday, December 28, 2005 8:57 AM
> To: mysql@stripped
> 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
> 


INFORMATION IN THIS MESSAGE, INCLUDING ANY ATTACHMENTS, IS INTENDED FOR THE PERSONAL AND
CONFIDENTIAL USE OF THE INTENDED RECIPIENT(S) NAMED ABOVE. If you are not an intended
recipient of this message, or an agent responsible for delivering it to an intended
recipient, you are hereby notified that you have received this message in error, and that
any review, dissemination, distribution, or copying of this message is strictly
prohibited. If you received this message in error, please notify the sender immediately,
delete the message, and return any hard copy print-outs.

This message has been scanned for viruses by McAfee's Groupshield.
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