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:[EMAIL PROTECTED] 
> Sent: Wednesday, December 28, 2005 8:57 AM
> To: mysql@lists.mysql.com
> 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.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to