title: Conditional JOIN Statement in MySQL
body: <p>I have the following, working MySQL query:</p>
  
  <pre><code>SELECT 
      a.id id,
      a.price price,
      a.stock stock,
      a.max_per_user max_per_user,
      a.purchased purchased, 
      b.quantity owned 
  FROM 
      shop_items a 
          JOIN shop_inventory b 
              ON b.iid=a.id 
              AND b.cid=a.cid 
  WHERE 
      a.cid=1 
      AND a.szbid=0 
      AND a.id IN(3,4)
  </code></pre>
  
  <p>The <code>JOIN</code> joins the table <code>shop_inventory b</code> to return <code>b.quantity owned</code>. However, if there is no record in the <code>shop_inventory b</code> table where <code>b.iid=a.id</code> I want it to return <code>b.quantity = 0</code>. How would I do this?</p>