title: Querying two tables at once in MySQL
body: <p>I have two tables; <code>productstorymap</code> and <code>stories</code>. <code>productstorymap</code> has <code>productId</code> and <code>storyId</code> columns. <code>stories</code> has <code>id</code> and <code>status</code> columns.</p>
  
  <p>I need to query all stories which belong to a certain product and have certain status. Closest thing I've got is</p>
  
  <pre><code>SELECT map.*, story.*
  FROM productstorymap map, stories story
  WHERE map.productId=1 AND story.status=1
  </code></pre>
  
  <p>But it returns me stories which don't belong to product 1. It returns something like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 1
              [productId] =&gt; 1
              [storyId] =&gt; 1
              [name] =&gt; Create a User Story
              [content] =&gt; Admin should be able to create user stories.
              [duration] =&gt; 1
              [priority] =&gt; 0
              [created] =&gt; 2010-09-22 17:36:21
              [edited] =&gt; 
              [status] =&gt; 1
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 4
              [productId] =&gt; 1
              [storyId] =&gt; 1
              [name] =&gt; Bar
              [content] =&gt; Xyzzy!
              [duration] =&gt; 
              [priority] =&gt; 1
              [created] =&gt; 2011-02-10 17:50:56
              [edited] =&gt; 2011-02-10 17:50:56
              [status] =&gt; 1
          )
  
  )
  </code></pre>
  
  <p>Even though productstorymap has only two rows:</p>
  
  <pre><code>ID  prodcutId   storyID
  1   1           1
  2   7           4
  </code></pre>
  
  <p>I'm using MySQL and PHP, if that is relevant.</p>