title: Transposing a column into three new columns in mysql
body: <p>I have a table in mysql with the following columns:</p>
  
  <p><a href="https://i.stack.imgur.com/yXIiJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yXIiJ.png" alt="enter image description here"></a></p>
  
  <p>Example of data:</p>
  
  <pre><code>'16', '1', 'Evening', '6.00', '2014-06-05 08:14:35', '2014-06-04', '6.00'
  '17', '2', 'Afternoon', '8.00', '2014-06-05 08:15:29', '2014-06-04', '8.00'
  '18', '3', 'Afternoon', '4.00', '2014-06-05 08:17:32', '2014-06-04', '4.00'
  '19', '4', 'Afternoon', '4.00', '2014-06-05 08:18:25', '2014-06-04', '4.00'
  '20', '17', 'Morning', '2.00', '2014-06-05 09:11:40', '2014-06-05', '2.00'
  '21', '17', 'Morning', '3.00', '2014-06-05 09:16:36', '2014-06-04', '3.00'
  '22', '17', 'Evening', '2.00', '2014-06-05 09:17:43', '2014-06-04', '2.00'
  '23', '19', 'Morning', '1.00', '2014-06-05 10:12:47', '2014-06-05', '1.00'
  '24', '20', 'Morning', '2.00', '2014-06-05 10:16:02', '2014-06-05', '2.00'
  '25', '22', 'Morning', '2.00', '2014-06-05 10:27:34', '2014-06-05', '2.00'
  '26', '23', 'Morning', '2.00', '2014-06-05 10:28:08', '2014-06-05', '2.00'
  '27', '24', 'Morning', '1.00', '2014-06-05 10:30:20', '2014-06-05', '1.00'
  '28', '27', 'Morning', '1.00', '2014-06-05 10:43:12', '2014-06-05', '1.00'
  '29', '27', 'Combined', '2.00', '2014-06-05 10:45:45', '2014-06-04', '2.00'
  '31', '28', 'Morning', '3.00', '2014-06-05 11:04:32', '2014-06-05', '3.00'
  </code></pre>
  
  <p>I would like to transpose the time column so that I have three new columns evening, afternoon and morning and record the quantity so that columns look like<br>
  <code>id, cow_id, Evening, Afternoon, Morning, date_added, date,quantity_type</code></p>
  
  <p>Could someone give me a solution on how to go about this with mysql query?       </p>