title: Laravel select random rows from table based on another field
body: <p>There is a <code>words</code> table with 20000 records: </p>
  
  <pre><code>ID      name      rank
  1       word1     3 
  2       word2     5019 
  3       word3     12334 
  4       word4     23
  5       word5     544
  </code></pre>
  
  <p>I want to select 400 words randomly from this table but with this condition : </p>
  
  <p><strong>first 20 words:</strong> select 20 words randomly from <code>words</code> with rank between 1 and 1000</p>
  
  <p><strong>second 20 words:</strong> select 20 words randomly from <code>words</code> with rank between 1000 and 2000</p>
  
  <p>And so on...</p>
  
  <p>Do I have to do this in 20 separate queries?  How? Is there a better way?</p>
  
  <p>I am using laravel 5.4 and Mysql, Also a raw query suggestion would be appreciated. Thank you</p>