title: Sql Statement: Insert On Key Update is not working as expected when primary key is not specified in the fields to insert
body: <p>Hello I am using the "INSERT ON DUPLICATE KEY UPDATE" sql statement to update my database.</p>
  
  <p>All was working fine since I always inserted an unique id like this:</p>
  
  <pre><code>INSERT INTO devices(uniqueId,name) 
      VALUES (4,'Printer') 
      ON DUPLICATE KEY UPDATE name = 'Central Printer';
  </code></pre>
  
  <p>But for now, I need to insert elements but I don't insert a unique id, I only insert or update the values like this:</p>
  
  <pre><code>INSERT INTO table (a,b,c,d,e,f,g)
      VALUES (2,3,4,5,6,7,8) 
      ON DUPLICATE KEY
          UPDATE a=a, b=b, c=c, d=d, e=e, f=f, g=g;
  </code></pre>
  
  <p>Have to say that an autoincrement primary key is generated always that I insert a row.</p>
  
  <p>My problem is that now the inserted rows are duplicated since I don't insert the primary key or unique id explicitly within the sql statement.</p>
  
  <p>What I am supposed to do?</p>
  
  <p>For example, maybe I  need to insert the primary key explicitly?  I would like to work with this primary autoincremented key.</p>
  
  <p>For recommendation from Gordon I am adding a sample case the you can see in the next image
  <a href="https://i.stack.imgur.com/FKpKj.png" rel="nofollow noreferrer">Rows Output</a></p>
  
  <p>In this case I add the first three rows, and then I try to update the three first rows again with different information.... Ok I am seeing the error... There is no key to compare to......  :$</p>
  
  <p>Thanks for your answers, </p>