title: MySQL: Return all rows of table A and true|false if record exists in table B
body: <p>I have a sales_cat table, and a user_cat table.</p>
  
  <p><strong>sales_cat</strong></p>
  
  <ul>
  <li>id_cat</li>
  <li>name</li>
  </ul>
  
  <p><strong>user_cat</strong></p>
  
  <ul>
  <li>id</li>
  <li>id_user</li>
  <li>id_cat</li>
  </ul>
  
  <p>I need to get all the sales_cat rows, joined with the user_cat table for a specific user, indicating if that user has or not the category. Example, for id_user = 4 it should return:</p>
  
  <pre><code>id_cat | name  | selected
  1      | kids  | 1
  2      | men   | 1
  3      | women | 0
  </code></pre>
  
  <p>Of course, the "selected" field is actually a value that depends on the existence of a linked record in user_cat. I've set a table structure in <a href="http://sqlfiddle.com/#!2/395ba" rel="nofollow">sqlfiddle</a>.</p>
  
  <p>My current solution only returns the linked data:</p>
  
  <pre><code>SELECT sales_cat.id_cat, sales_cat.name
  FROM sales_cat
  LEFT JOIN user_cat ON user_cat.id_cat = sales_cat.id_cat
  WHERE user_cat.id_user = 4
  </code></pre>
  
  <p>...which is returning:</p>
  
  <pre><code>id_cat | name
  1      | kids
  2      | men
  </code></pre>
  
  <p>I'm still missing the "selected" column and the <strong>3 | women</strong> row.</p>
  
  <p>Any ideas? Thanks!</p>