title: too many SQL variables and NOT IN clause
body: <p>I have a table with a collection of ids (sqlite Android), and a collection of ids I want to retain.</p>
  
  <p>Then if toRetain = [1,2,3,4] I create an execute:</p>
  
  <pre><code>DELETE FROM my_items WHERE _id NOT IN (1,2,3,4);
  </code></pre>
  
  <p>But if the length of the items to retain is very high the SQL engine throws an exception: <strong>"too many SQL variables"</strong>. Since the clause is NOT IN I can't do it in smaller steps.</p>
  
  <p>How can i solve it?</p>
  
  <p>One solution I think is to insert all the ids in a temporal table and then execute:</p>
  
  <pre><code>DELETE FROM my_items WHERE _id NOT IN (SELECT_id FROM items_to_delete);
  </code></pre>
  
  <p>Is that solution correct and efficient?? </p>