1
我有3列A,B,C和A中的獨特和BMySQL的 - 插入或更新,並得到舊值
從客戶端我傳遞一些值插入或更新C如果表SomeTable一個,B已經存在。 我想知道,如果服務器已經做了更新或插入每個值,如果它是一個更新我想C的舊值....
我目前做這與
While values to insert {
Insert A,B,C
if success memorizing the value continue the while
else if the sql error is "duplicate key" {
select old value of C for A,B
update C for A,B...
}
}
這意味着3次調用MySQL ....
有沒有辦法用觸發器,過程或「魔術」查詢做到這一點?
你想[上重複鍵更新](http://stackoverflow.com/a/1361368/112968)或'REPLACE'? – knittl