title: mysql : select the last action of each user
body: <p>I have a table like this:</p>
  
  <pre><code>ActionTime              UserID        Score
  2011-08-15 12:06:00       1              14
  2011-08-15 14:45:00       2              17
  2011-08-16 12:17:00       1              20   &lt;== select this row
  2011-08-16 04:28:00       2              14
  2011-08-17 06:52:00       2              16   &lt;== select this row
  </code></pre>
  
  <p>I want to find out the Score and ActionTime of each user in their last action. (as indicated above)</p>
  
  <p>I know I can do it one by one like this: </p>
  
  <pre><code>SELECT * from MyTable WHERE UserID=? ORDER BY ActionTime DESC LIMIT 1
  </code></pre>
  
  <p>But we have hundreds of different UserID (and it keeps increasing of course). This will cause large amount of PHP-to-MySQL communications which is unacceptable.</p>
  
  <p>I just wonder if it is possible to get all the rows at once execution / communication?</p>