title: Can I fire two select statements in a single MySQL command and count resulting rows?
body: <p>Here's my code as is, working, but very slow:</p>
  
  <pre><code>    $graded = R::getAll("SELECT posts.id, posts.discussion, rating.rating, rating.itemid
                               FROM uv_forum_posts posts
                               JOIN uv_rating rating ON ( posts.id = rating.itemid )
                               WHERE posts.discussion = :discussion_id
                               GROUP BY posts.userid",
                               array(':discussion_id' =&gt; $discussion['id']));
  
      $total = R::getAll("SELECT posts.userid
                          FROM uv_forum_posts posts
                          WHERE posts.discussion = :discussion_id
                          GROUP BY userid",
                          array(':discussion_id' =&gt; $discussion['id']));
  
      $percentages[] = count($graded) / count($total) * 100;
  </code></pre>
  
  <p><code>$graded</code> represents all rows that have a rating.</p>
  
  <p><code>$total</code> represents all user participation, regardless of being graded or not.</p>
  
  <p>I'm only interested in the numerical values of the resulting sets, can I combine these two MySQL calls into a single call that returns two numbers <code>graded</code> and <code>total</code>?</p>