title: MYSQL Trigger to create horizontal table from vertical
body: <p>i have a table with this vertical structure. The Data comes from an external company so i have do deal with it.</p>
  
  <pre><code>+----+-----------+------+--------+
  | id | status_id | key  | value  |
  +----+-----------+------+--------+
  |  1 |       100 | key1 | value1 |
  |  2 |       100 | key2 | value2 |
  |  3 |       100 | key3 | value3 |
  |  4 |       200 | key1 | value1 |
  |  5 |       200 | key2 | value2 |
  |  6 |       200 | key3 | value3 |
  +----+-----------+------+--------+
  </code></pre>
  
  <p>Now i wanted to create a horizontal table from this data with a trigger after insert, so that i become this structure..</p>
  
  <pre><code>+-----------+--------+--------+--------+
  | status_id |  key1  |  key2  |  key3  |
  +-----------+--------+--------+--------+
  |       100 | value1 | value2 | value3 |
  |       200 | value1 | value2 | value3 |
  +-----------+--------+--------+--------+
  </code></pre>
  
  <p>The status_id becomes unique so i tried an <code>INSERT</code> with <code>ON DUPLICATE KEY</code> but i don't know how do i have to write it that the value from key becomes the field name for the insert.</p>
  
  <p>Many greetings
  Kevin</p>