title: Joining same table with NULL values in MySQL
body: <p>I have a simple table like</p>
  
  <pre><code>user_id | meta_key | meta_value
  ===============================
     1    | color    | green
     2    | color    | red
     1    | size     | L
     2    | size     | L
     3    | color    | blue
  
  ...
  </code></pre>
  
  <p>Now I like a single query where I get all colors and sizes of a certain user</p>
  
  <pre><code>SELECT a.user_id AS ID, a.meta_value AS color, b.meta_value AS size
     FROM table AS a
     LEFT JOIN table AS b ON a.user_id = b.user_id 
  WHERE a.meta_key = 'color' AND b.meta_key = 'size' GROUP BY a.meta_value, b.meta_value
  </code></pre>
  
  <p>This works as long I have a <code>size</code> for each user. If <code>size</code> is missing (ID 3 in example) the user isn't in the result</p>