title: MySql on duplicate key set last_insert_id is causing auto_increment to jump
body: <p>I have a query that goes as follows:</p>
  
  <pre><code>insert into TABLE(COLUMNS) values(VALUES) on duplicate key update id=last_insert_id(id)
  </code></pre>
  
  <p>I use this to get an ID of inserted or existing row of data. </p>
  
  <pre><code>$id=$connection-&gt;lastinsertid();
  </code></pre>
  
  <p>Well now I have a issue with my <code>auto_increment</code> jumping with each duplicate key update.</p>
  
  <p><a href="https://i.stack.imgur.com/afQ46.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/afQ46.png" alt="enter image description here"></a></p>
  
  <p>I am fairly certain <code>on duplicate key</code> update part is causing these jumps. Is this the source of the problem? Is there a way to fix this within the query without reseting <code>auto_increment</code> entirely every time? </p>