1

In a SQL query I use the (MySQL database)

INSERT ... UPDATE ON DUPLICATE KEY 

statement in order to insert or update.

I would like to know if an insert has been made or an update.

I use mysql_insert_id() but the problem I am having is that it does return the row id whether I am inserting or updating.

mmking
  • 1,564
  • 4
  • 26
  • 36
  • This is documented in [the `ON DUPLICATE KEY UPDATE`](http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html) docs. Check `mysql_affected_rows()` which should report 1 for an insert and 2 for an update. – Michael Berkowski Jan 26 '15 at 16:48

0 Answers0