title: how to select 3 random items of each category?
body: <p>I need some help writing a select query basically I have the table structured as below:</p>
  
  <pre>
  cat_prod
  ----------
  cid | pid
  ----------
   1 | 1
   2 | 2
   3 | 3
   4 | 4
   5 | 5
   1 | 2
   2 | 3
   3 | 4
   4 | 5
   5 | 1
   1 | 3
   2 | 4
   3 | 5
   4 | 1
   5 | 2
  
  
  </pre>
  
  <p>Now I would like to select at least 3 random pid's of each cid where it exists or the maximum pid's if less than 3, how would i do that in one query? Baring in mind I would like the query to be as efficent as possible and that the table data is likely to grow considerablly.</p>
  
  <p>Thanks</p>