title: Select random row with other criteria
body: <p>I have seen <a href="https://stackoverflow.com/questions/4329396/mysql-select-10-random-rows-from-600k-rows-fast#answer-4329447">this great answer</a> on how to select a random row from a table and it works great on my table. Modifying that query I ended up with:</p>
  
  <pre><code>SELECT r1.clID, clUserName, clCompanyName, clBio 
  FROM customerlogin AS r1 JOIN 
  (
      SELECT 
      (
          RAND() * 
          (
              SELECT MAX(clID) 
              FROM customerlogin)) 
      AS clID) 
  AS r2 
  WHERE r1.clID &gt;= r2.clID 
  ORDER BY r1.clID ASC LIMIT 1
  </code></pre>
  
  <p>However I need to go one step further and limit the possible answers to those that match certain criteria.</p>
  
  <p>I think the best way to do this would to be to build a temporary table, selecting only the valid rows from the original table, and then select a random row from the temporary table, however I am unsure on how to go about doing this. I've tried googling various combinations of create and select from random table, but with no joy so far. I'm assuming I just don't know the right way to ask what I'm after.</p>
  
  <p>Can anybody please point me to a guide or some example code on how this can be accomplished? Or if there is a better solution I am overlooking then I am open to suggestions.</p>