title: MySQL: Alternatives to ORDER BY RAND()
body: <p>I've read about a few alternatives to MySQL's <code>ORDER BY RAND()</code> function, but most of the alternatives apply only to where on a single random result is needed. </p>
  
  <p>Does anyone have any idea how to optimize a query that returns multiple random results, such as this: </p>
  
  <pre><code>   SELECT u.id, 
            p.photo 
       FROM users u, profiles p 
      WHERE p.memberid = u.id 
        AND p.photo != '' 
        AND (u.ownership=1 OR u.stamp=1) 
   ORDER BY RAND() 
      LIMIT 18 
  </code></pre>