title: SQL: Insert only new rows/records into a table?
body: <p>I'm parsing a json feed routinely and need to insert only the newest users from the feed and ignore existing users.</p>
  
  <p>I think what I need is <code>ON DUPLICATE KEY UPDATE</code> or <code>INSERT IGNORE</code> based on some searching but I'm not quite sure which is why I'm asking - so for example:</p>
  
  <pre><code>users
  1     John
  2     Bob
  </code></pre>
  
  <p>Partial JSON:</p>
  
  <pre><code>{ userid:1, name:'John' },
  { userid:2, name:'Bob' },
  { userid:3, name:'Jeff' }
  </code></pre>
  
  <p>From this feed I only want to insert Jeff. I could do a simple loop through all users and do a simple SELECT query and see if the user id is already in the table, if not I do an INSERT, however I suspect it won't be an efficient and practical method. </p>
  
  <p>By the way, I'm using Zend_Db for the database interaction if anyone would like to cater a specific answer :) I don't mind a generic strategic solution though.</p>