1

I have a table with such kind of data in 2 columns:

TypeOfFruits | Production2014 |
Mangoes         450
Mangoes         100
Berries         50
Berries         75
Mangoes         45
Berries         25    

My question is: How can I query the data from those two columns so that I can get a result in new columns like:

production2014 for Mangoes | production2014 for Berries
450                          50
100                          75
45                           25
sulhadin
  • 521
  • 4
  • 16
Nsengiyunva
  • 11
  • 1
  • 9

1 Answers1

0

Using PIVOT,UNPIVOT in mysql would achive what you want.

Here I found an old discussion about using PIVOT properly,

MySQL pivot table

and here; http://stratosprovatopoulos.com/web-development/mysql/pivot-a-table-in-mysql/

Community
  • 1
  • 1
sulhadin
  • 521
  • 4
  • 16