title: Sorting table into new table
body: <p>I have been trying to figure this one out for ages so decided to turn here.</p>
  
  <p>I currently have a database that has a ton of rows but as an example it looks like the below:</p>
  
  <pre><code> ___________________________________
  |  column1  |  column2  |  column3  |
  |-----------------------------------|
  | 123       |     UK    | answeruk1 |
  | 321       |     UK    | answeruk3 |
  | 111       |     EN    | answeren2 |
  | 321       |     EN    | answeren3 |
  | 111       |     FR    | answerfr2 |
  | 123       |     FR    | answerfr1 |
  | 111       |     UK    | answeruk2 |
  | 321       |     FR    | answerfr3 |
  | 123       |     EN    | answeren1 |
  </code></pre>
  
  <p>I am trying to get this to be inserted into a new table so the structure is like the below:</p>
  
  <pre><code> _______________________________________________
  |  column1  |  column2  |  column3  |  column4  |
  |-----------|-----------|-----------|-----------|
  | 123       | answerfr1 | answeruk1 | answeren1 |
  | 321       | answerfr3 | answeruk3 | answeren3 |
  | 111       | answerfr2 | answeruk2 | answeren2 |
  </code></pre>
  
  <p>This is so they are all organised by column1 but are in columns by there respective country code found in column2</p>
  
  <p>I have tried using INSERT INTO but i can't seem to get my head around how i can sort 3 columns at the same time with 1 query. There are also a ton(around 15,000-20,000) of id's (the number found in column1).</p>
  
  <p>I have also tried using PHP which i think may be the only way of doing this maybe within a while statement to loop through all the id's?</p>
  
  <p>Thanks in advance.</p>