title: MySQL query with LEFT OUTER JOIN and WHERE
body: <p>I have three tables: <code>stories</code>, <code>story_types</code>, and <code>comments</code></p>
  
  <p>The following query retrieves all of the records in the <code>stories</code> table, gets their <code>story_types</code>, and the number of comments associated with each story:</p>
  
  <pre><code>         SELECT s.id AS id,
                  s.story_date AS datetime,
                  s.story_content AS content,
                  t.story_type_label AS type_label,
                  t.story_type_slug AS type_slug,
                  COUNT(c.id) AS comment_count
             FROM stories AS s
  LEFT OUTER JOIN story_types AS t ON s.story_type_id = t.id
  LEFT OUTER JOIN comments AS c ON s.id = c.story_id 
         GROUP BY s.id;
  </code></pre>
  
  <p>Now what I want to do is only retrieve a record from <code>stories WHERE s.id = 1</code> (that's the primary key). I have tried the following, but it still returns all of the records:</p>
  
  <pre><code>         SELECT s.id AS id,
                  s.story_date AS datetime,
                  s.story_content AS content,
                  t.story_type_label AS type_label,
                  t.story_type_slug AS type_slug,
                  COUNT(c.id) AS comment_count
             FROM stories AS s
  LEFT OUTER JOIN story_types AS t ON s.story_type_id = t.id
                  AND s.id = 1
  LEFT OUTER JOIN comments AS c ON s.id = c.story_id 
         GROUP BY s.id;
  </code></pre>
  
  <p>I have also tried a <code>WHERE</code> clause at the end, which throws an error.</p>
  
  <p>Can someone point out the correct syntax for a condition like this in this situation?</p>
  
  <p>I'm using MySQL 5.1.47. Thanks.</p>