Lets think of a situation: where you have to bulk insert,
but there might be some data which is already there in the db, and you just want to modify it.
In such cases, something like the following query will help you.InsertThe key is to use the clause "On Duplicate Key Update"
Into t1 (id,val1,va2)
Values (1,1,1),(2,2,2),(3,3,3)
On Duplicate Key Update
val1= val1+ values(val1),
val2= val2 + values(val2)
Thursday, February 19, 2009
Mysql: Bulk Inserts involving updates
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment