Getting count of insert/update rows from ON DUPLICATE KEY UPDATE
问题 I have a statement that tries to insert a record and if it already exists, it simply updates the record. INSERT INTO temptable (col1,col2,col3) VALUES (1,2,3) ON DUPLICATE KEY UPDATE col1=VALUES(col1), col2=VALUES(col2), col3=VALUES(col3); The full statement has multiple inserts and I'm looking to count number of INSERTs against the UPDATEs. Can I do this with MySQL variables, I've yet to find a way to do this after searching. 回答1: From Mysql Docs In the case of "INSERT ... ON DUPLICATE KEY