title: mySQL how to unpivot dynamic columns
body: <p>I have the following table below:</p>
  
  <p>Table name: STAT</p>
  
  <pre><code>Region   M07  M08 M09 
  ---------------------
  P1       0    1   0    
  P2       0    0   0   
  P3       2    0   0    
  P4       0    0   0     
  P5       0    0   0     
  P6       0    0   0   
  P7       9    0   3  
  </code></pre>
  
  <p>I would like to UNPIVOT the months columns, which contain numerical values. This Months column headers are DYNAMIC and will be changing, but the total number of columns will remain the same.</p>
  
  <p>Expected Result</p>
  
  <pre><code>---------------------
  Region   Month  Qty
  ---------------------
  P1      M07    0
  P1      M08    1
  P1      M09    0
  P2      M07    0
  P2      M08    0
  P2      M09    0
  </code></pre>
  
  <p>It would be great if I can have some help writing this SQL statement to UNPIVOT and then also consider the dynamic nature of the numerical columns.
  It should written in mySQL.</p>