Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql中如何使用同一表中两列的结果_Mysql_Sql_Subquery_Mysql Workbench - Fatal编程技术网

mysql中如何使用同一表中两列的结果

mysql中如何使用同一表中两列的结果,mysql,sql,subquery,mysql-workbench,Mysql,Sql,Subquery,Mysql Workbench,我有一个表,有两列这样的数据: TypeOfFruits | Production2014 | Mangoes 450 Mangoes 100 Berries 50 Berries 75 Mangoes 45 Berries 25 我的问题是:如何从这两列中查询数据,以便在新列中获得结果,如: production2014 for Mangoes | production2014 for B

我有一个表,有两列这样的数据:

TypeOfFruits | Production2014 |
Mangoes         450
Mangoes         100
Berries         50
Berries         75
Mangoes         45
Berries         25    
我的问题是:如何从这两列中查询数据,以便在新列中获得结果,如:

production2014 for Mangoes | production2014 for Berries
450                          50
100                          75
45                           25

在mysql中使用
PIVOT
UNPIVOT
将实现您想要的

在这里,我找到了一个关于正确使用PIVOT的老讨论

在这里;

在mysql中使用
PIVOT
UNPIVOT
将实现您想要的

在这里,我找到了一个关于正确使用PIVOT的老讨论

在这里;

可能会有多少种不同的
水果呢?只有芒果和浆果!可能有多少种不同的水果呢?只有芒果和浆果!哦…让我看看#谢谢…让我看看#谢谢