title: JOIN two tables to show already purchased items
body: <p>I have a table where I keep all my templates:</p>
  
  <p><strong>templates</strong></p>
  
  <ul>
  <li>template_id</li>
  <li>template_name</li>
  <li>template_price</li>
  </ul>
  
  <p>These templates can be purchased by a registered user and then are inserted in the <code>payments</code> table:</p>
  
  <p><strong>payments</strong></p>
  
  <ul>
  <li>payment_id</li>
  <li>template_id</li>
  <li>user_id</li>
  </ul>
  
  <p>Is there a way to join these two tables and get not just a list of templates that have been purchased by a certain user, but all the templates? And then figure out from there which ones have already been purchased?</p>
  
  <p>I used this SELECT, but only the ones that the user bought showed up. I would like to have all the rows from <code>templates</code>, but empty in case the <code>user_id</code> doesn't match.</p>
  
  <pre><code>SELECT *
  FROM templates
  LEFT JOIN payments
  ON templates.template_id = payments.template_id
  WHERE user_id = 2
  GROUP BY templates.template_id
  </code></pre>