title: mysql pivot table with string values
body: <p>I have a table with just two columns like this</p>
  
  <pre><code>mysql&gt; select * from stuff_table;
  +------+-------+
  | name | stuff |
  +------+-------+
  | John | shoes |
  | Jim  | bag   |
  | Ely  | book  |
  | Tom  | bag   |
  | Will | shoes |
  | Pitt | book  |
  | Dean | bag   |
  | Luke | bag   |
  +------+-------+
  </code></pre>
  
  <p>and I tried with many solutions I found like</p>
  
  <pre><code>select distinct
  max(case when stuff='shoes' then name else name is null) end as shoes,
  max(case when stuff='bag' then name else name is null end) as bag,
  max(case when stuff='book' then name else name is null end) as book
  from stuff_table;
  </code></pre>
  
  <p>but I just got this</p>
  
  <pre><code>+-------+------+------+
  | shoes | bag  | book |
  +-------+------+------+
  | Will  | Tom  | Pitt |
  +-------+------+------+
  </code></pre>
  
  <p>Instead, I want to get this</p>
  
  <pre><code>+-------+------+------+
  | shoes | bag  | book |
  +-------+------+------+
  | John  | Jim  | Ely  |
  | Will  | Tom  | Pitt |
  | NULL  | Dean | NULL |
  | NULL  | Luke | NULL |
  +-------+------+------+
  </code></pre>
  
  <p>I have tried with sum(case...) or if(case..) or group by too but it doesn't work. Is there any mysql query to get such that table? Kindly help. Thank you.</p>