title: Mysql duplicate primary key error - but key does not exist in db
body: <p>I am trying to insert multiple rows into the database. Out of 23,000 insert statements, ~600 are failing in this manner:</p>
  
  <p>example query:</p>
  
  <pre><code>INSERT INTO authorization_codes (book_id, auth_code, unpaid) 
  (SELECT edition_nid,'FLT9950526', 1 
   FROM catapult.editions WHERE isbn_digital = '978-1-4533-2704-3');
  </code></pre>
  
  <p>error message:</p>
  
  <blockquote>
    <p>[ERROR in query 2800] Duplicate entry 'FLT9950526' for key 'PRIMARY'</p>
  </blockquote>
  
  <p>The primary key in this case is '<code>auth_code</code>'</p>
  
  <pre><code>select * from authorization_codes where auth_code = 'FLT9950526';
  </code></pre>
  
  <p>this returns no rows.</p>
  
  <p>More clues- in the script I am running with multiple insert statements, the errors happen consecutively in the file. </p>
  
  <p>When I take the query out of the script- it errors the same way, with a duplicate entry error.</p>
  
  <p>What am I doing to cause this?</p>
  
  <p>(edit- sorry, cut &amp; paste error, grabbed wrong error row, thanks @juergen-d)</p>