title: MySQL PivotTable - How to convert dynamic columns to rows?
body: <p>I would like to transform the following database table from dynamic columns to rows in MySQL:</p>
  
  <p>I already took a deep look at stackoverflow.com as well as at this great example <a href="http://buysql.com/mysql/14-how-to-automate-pivot-tables.html" rel="nofollow">here</a> but none of the cases matches my requirement.<br>
  The example shown from the link above would match my requirements if it would be dynamic (I do not know the value 'color' or 'size' because it changes dynamically):<br></p>
  
  <pre><code>SELECT
  item_id,
  MAX(IF(property_name = 'color', value, NULL)) AS color,
  MAX(IF(property_name = 'size', value, NULL)) AS size,
  ...
  ...
  ...
  FROM
  properties
  GROUP BY
  item_id;
  </code></pre>
  
  <p><br/>
  So this is my Database Table:<br/>
  <br/></p>
  
  <pre><code>id | customer_id | customer_tbl_id | customer_tbl_col_name
   1 |           1 |               1 | CustomerColName_1
   2 |           1 |               1 | CustomerColName_2
   3 |           1 |               1 | CustomerColName_3
   4 |           1 |               2 | CustomerColName_4
   5 |           1 |               2 | CustomerColName_5
   6 |           2 |               1 | CustomerColName_6
   7 |           2 |               1 | CustomerColName_7
  </code></pre>
  
  <p>Now the result of my SQL query should be like this:</p>
  
  <pre><code>1 (customer_id) | 1 (customer_tbl_id) | CustomerColName_1 | CustomerColName_2 | CustomerColName_3
  1 (customer_id) | 2 (customer_tbl_id) | CustomerColName_4 | CustomerColName_5
  2 (customer_id) | 1 (customer_tbl_id) | CustomerColName_6 | CustomerColName_7
  </code></pre>