insert into table1 (fa,fb,qty) values (fa1,fb1,qty1) on duplicate key
update qty=qty+qty1
a primarykey or unique key must.
Shuming Wang
[EMAIL PROTECTED] wrote:
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 con
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 ta
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/ins