title: Retrieve rows grouped by hour with MySQL
body: <p>I have a table containing access logs. I want to know how many accesses to resource_id '123' occured in each hour in a 24 hour day.</p>
  
  <p>My first thought for retrieving this info is just looping through each hour and querying the table in each loop with something like... <code>and time like '$hour:%'</code>, given that the <code>time</code> field holds data in the format <code>15:47:55</code>.</p>
  
  <p>Is there a way I can <code>group by</code> the hours and retrieve each hour and the number of rows within each hour in a single query?</p>
  
  <p>Database is MySQL, language is PHP.</p>