title: MySQL group multiple(variable) rows into one row with multiple columns
body: <p>I'm looking for a query that will return me several rows into columns but without knowing the number of rows beforehand. I have searched and the only solutions I found involve knowing how many rows there are.</p>
  
  <p>Here's an example table:</p>
  
  <pre><code>parentID    colA       colB
  2           aaaaaa     1000.00
  2           bbbbbb     1500.00
  3           cccccc     500.00
  3           dddddd     700.00
  3           eeeeee     2000.00
  </code></pre>
  
  <p>and i need it to look like:</p>
  
  <pre><code>parentID    colA(n)      colB(n)     colA(n+1)     colB(n+1)     colA(n+2)     colB(n+2)
  2           aaaaaaa      1000.00     bbbbbb        1500.00       NULL          NULL
  3           cccccc       500.00      dddddd        700.00        eeeeee        2000.00
  </code></pre>
  
  <p>I realize this should be done in PHP but I need it to be in mysql for a third party excel exporter plugin I'm using.</p>
  
  <p>Edit: Is there a way to do this if I know the maximum number of columns I'll need?</p>