title: Is there a way to do a "INSERT INTO with auto_increment if not exists"?
body: <p>I have a table that looks like this:</p>
  
  <pre><code>| ID | int PRIMARY  
  | Name | varchar  
  | timestamp | timestamp
  </code></pre>
  
  <p>How do I do this knowing an ID?</p>
  
  <p>To show you better what I want, here's an example using two queries to help you understand better:</p>
  
  <p>1st I just do a SELECT query to see if the ID exists.<br>
  if it does not exist (the most common), I create a new row ignoring the ID I was given as input and I use MySQL's AUTO_INCREMENT for the ID.</p>
  
  <p>Is there a way to archive this?</p>
  
  <p><strong>Note:</strong> Due to how foreign keys work here. using the REPLACE instead of INSERT INTO is <strong>not</strong> an answer.</p>
  
  <p><strong>Note2:</strong> Because I want to force the use of the AUTO_INCREMENT if it does not exist, at first glance, the INSERT IGNORE INTO also does not seem to be the answer. Unless I'm missing something... That's also why I'm asking.</p>