title: How to select RAND() between 1-n
body: <p>I'd like to use <code>RAND()</code> in a query to be able to do the following:</p>
  
  <p><code>ODER BY id DESC</code> and allow <code>RAND()</code> to choose between last 3 inserted rows in the table. On the front-end when page is refreshed function rand will choose between 5 - 8 (on the table example) and show any data between those numbers.</p>
  
  <h2>Query Example</h2>
  
  <pre><code>function rand()
  {
      $sth = $this-&gt;db-&gt;prepare("SELECT rows FROM table ORDER BY id LIMIT 1");
      $sth-&gt;execute();
  
  }
  </code></pre>
  
  <h2>Table Example</h2>
  
  <pre><code>+--------------+
  | id |   name  |
  +--------------+
  |  1 |    Jon  |
  |  2 |  Sarah  |
  |  3 | Stevie  |
  |  4 |   Stew  |
  |  5 |   Dave  |
  |  6 |    Kar  |
  |  7 |  Stevo  |
  |  8 |  Blake  |
  +----+---------+
  </code></pre>
  
  <hr>
  
  <h2>EDIT</h2>
  
  <p>+----+
  | id |
  +----+
  |    |
  |    |
  |    |
  |    |
  |    |
  |    |
  |    |
  |    ||    |  </p>