title: Optimize query when selecting specific prime numbers from table
body: <p>I have the following table:</p>
  
  <p><a href="https://i.stack.imgur.com/VinEr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VinEr.jpg" alt="table"></a></p>
  
  <p>I need one query which will return a result based on the following rules:</p>
  
  <ul>
  <li>those lines that contain more that 3 prime numbers  </li>
  <li>those lines that contain less than 3 prime numbers</li>
  <li>those lines that contain between 1 and 3 prime numbers  </li>
  </ul>
  
  <p>Supposing that my table is named <code>numbers_table</code> and supposing that the table could be really large, what would be the adequate query that should be run in mysql ?</p>
  
  <p>What I've done so far:</p>
  
  <pre><code>SELECT nr1,nr2,nr3,nr4,nr5,nr6 FROM numbers where 
    nr1 in (2, 3, 5, 7, 11, 13, 23, 29, 31, 37, 41, 43, 47) or
    nr2 in (2, 3, 5, 7, 11, 13, 23, 29, 31, 37, 41, 43, 47) or
    nr3 in (2, 3, 5, 7, 11, 13, 23, 29, 31, 37, 41, 43, 47) or
    nr4 in (2, 3, 5, 7, 11, 13, 23, 29, 31, 37, 41, 43, 47) or
    nr5 in (2, 3, 5, 7, 11, 13, 23, 29, 31, 37, 41, 43, 47) or
    nr6 in (2, 3, 5, 7, 11, 13, 23, 29, 31, 37, 41, 43, 47);
  </code></pre>
  
  <p>Can I optimize the above solution ?</p>