title: MySQL - Export data with desired form from table
body: <p>The story is that I received a table with the following structure</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Item</th>
  <th>Attribute</th>
  <th>Value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>ABC123</td>
  <td>AttrName1</td>
  <td>Value1</td>
  </tr>
  <tr>
  <td>ABC123</td>
  <td>AttrName2</td>
  <td>Value2</td>
  </tr>
  <tr>
  <td>ABC123</td>
  <td>AttrName3</td>
  <td>Value3</td>
  </tr>
  <tr>
  <td>DEF456</td>
  <td>AttrName1</td>
  <td>Value1</td>
  </tr>
  <tr>
  <td>DEF456</td>
  <td>AttrName2</td>
  <td>Value2</td>
  </tr>
  <tr>
  <td>DEF456</td>
  <td>AttrName3</td>
  <td>Value3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to export to CSV with the better form to do import, following by</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Item</th>
  <th>AttrName1</th>
  <th>AttrName2</th>
  <th>AttrName3</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>ABC123</td>
  <td>Value1</td>
  <td>Value2</td>
  <td>Value3</td>
  </tr>
  <tr>
  <td>DEF456</td>
  <td>Value1</td>
  <td>Value2</td>
  <td>Value3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Is there any SQL statement that can do this? Or is an idea to implement a short script to handle this? Thanks</p>