Hi,
what you want to look into is (depending on your version)
either "INSERT ... ON DUPLICATE KEY UPDATE ..." or REPLACE
http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html
http://dev.mysql.com/doc/refman/5.0/en/replace.html
/Johan
[EMAIL PROTECTED] skrev:
Hi,
I want to update a table if it meets some conditions (already exist) and
INSERT otherwise?
Right now I am doing it this way:
1. SELECT the record
2. If it exist, I UPDATE it
3. If it does not exit, I INSERT a new record
Could this be done in one query? I mean like conditional update/insert?
/Peter
--MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
--No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.5.5/769 - Release Date:
2007-04-19 17:56
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]