我无法使用以下表格在 MySQL 中创建数据透视表:
Teams
-------------
id | name
1 | teamA
2 | teamB
Processes
-------------
id | name
1 | processA
2 | processB
3 | processC
ProcessDetails
---------------
id | processId | keyName
1 | 1 | shape
2 | 1 | vegetable
3 | 1 | fruit
4 | 2 | animal
5 | 3 | dessert
TeamProcesses
-----------------
id | teamId | processId
5 | 1 | 1
6 | 1 | 2
7 | 2 | 3
TeamProcessDetails
--------------------
id | teamProcessId | proccessDetailsId | value
1 | 5 | 1 | circle
2 | 5 | 2 | carrot
3 | 5 | 3 | apple
4 | 6 | 4 | dog
5 | 7 | 5 | chocolate
我尝试生成的数据透视表应仅包含给定团队的流程详细信息。
例子
对于 A 队:
Pivot Table
------------
teamId | processId | shape | vegetable | fruit | animal
1 | 1 | circle | carrot | apple | NULL
1 | 2 | NULL | NULL | NULL | dog
B组:
teamId | processId | dessert
2 | 3 | chocolate
谢谢!