title: MySQL: is there a limit to the entries of an "IN" clause?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1532366/mysql-number-of-items-within-in-clause">MySQL number of items within &ldquo;in clause&rdquo;</a><br>
    <a href="https://stackoverflow.com/questions/2426331/in-mysql-or-postgres-is-there-a-limit-to-the-size-of-an-in-1-2-n-statement">In mysql or postgres, is there a limit to the size of an IN (1,2,n) statement?</a>  </p>
  </blockquote>
  
  
  
  <p>I build an "IN" list dynamically and I was wondering if there is a limit to the size of the IN clause in mysql.</p>
  
  <pre><code>SELECT foo FROM bar WHERE bar_key IN ('prod1', 'prod2', 'prod50', ...'last prod')
  </code></pre>
  
  <p>I imagine there is a limit to the total length of a SQL statement but I can't find it in the manual.</p>
  
  <p>I do know that an alternative is to build a temp table and join with it, though I'm not sure where the performance tradeoff exists if I have to execute many INSERT statements. Of course if I could populate the temp table with a single INSERT that would be fast, but that's not possible in my case.</p>
  
  <p>So my first question is what are the mysql limits and I'd appreciate if you can point me to relevant pages in the manual.</p>