title: Two left joins and records from the last hour
body: <pre><code>SELECT p.*, 
         u.user_id, 
         u.user_name, 
         count(c.comment_post_id) AS comments, 
         c.comment_added 
      FROM posts as p 
          LEFT JOIN comments as c 
              ON (p.post_id=c.comment_post_id) 
          LEFT JOIN users as u 
              ON (p.postedby_id = u.user_id) 
      GROUP BY p.post_id 
      HAVING c.comment_added &gt; NOW() - INTERVAL 1 HOUR 
      ORDER BY comments DESC
  </code></pre>
  
  <p>I'm not very good at mysql, but after a little research I managed to write this.</p>
  
  <p>What's supposed to happen here is a list of posts, ordered by whichever has the most comments within the last hour. My noobscript should be able to explain the important parts of the DB structure. Some of the SELECTed items is for php purposes.</p>
  
  <p>What is wrong with my script?</p>