title: mysql converting multiple rows into columns in a single row
body: <p>i have a details table with columns:</p>
  
  <ul>
  <li>user_id int</li>
  <li>code int</li>
  <li>value int</li>
  </ul>
  
  <p>And i want to build a summary table that looks like:</p>
  
  <ul>
  <li>user_id int</li>
  <li>valueA int</li>
  <li>valueB int</li>
  </ul>
  
  <p>In the details table, valueA would correspond to say, code 5, and valueB would correspond to say, code 6, so i'm looking for something like:</p>
  
  <p>insert into summary (user_id,valueA,valueB) VALUES ( SELECT ??? from details );</p>
  
  <p>The problem of course is that i'm looking at multiple rows from the "details" table to populate one row in the "summary" table.</p>
  
  <p>Eg, if i had the following rows in details:</p>
  
  <pre><code>1  5  100
  1  6  200
  2  5  1000
  2  6  2000
  </code></pre>
  
  <p>I want to end up with the following in the summary table:</p>
  
  <pre><code>1  100   200
  2  1000  2000
  </code></pre>
  
  <p>Any ideas?</p>