update or insert if necessary?

2005-12-28 Thread steve
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

Re: update or insert if necessary?

2005-12-28 Thread Jeremiah Gowdy
http://dev.mysql.com/doc/refman/5.0/en/replace.html - Original Message - From: steve [EMAIL PROTECTED] To: mysql@lists.mysql.com 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

Re: update or insert if necessary?

2005-12-28 Thread Jeremiah Gowdy
Actually, you may be more interested in: INSERT . ON DUPLICATE KEY UPDATE - Original Message - From: steve [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Wednesday, December 28, 2005 6:57 AM Subject: update or insert if necessary? I have a situation where I need to update

RE: update or insert if necessary?

2005-12-28 Thread John Trammell
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