title: MySQL ON DUPLICATE KEY - last insert id?
body: <p>I have the following query:</p>
  
  <pre><code>INSERT INTO table (a) VALUES (0)
    ON DUPLICATE KEY UPDATE a=1
  </code></pre>
  
  <p>I want the ID of either the insert or the update. Usually I run a second query in order to get this as I believe insert_id() only returns the 'inserted' ID and not the updated ID.</p>
  
  <p>Is there a way to INSERT/UPDATE and retrieve the ID of the row without running two queries?</p>