mysql - MySQL - 行作为具有值的列
问题描述
一段时间以来,我一直在寻找高性能的 MySQL Query 解决方案。希望有人可以帮助我。
我的表看起来像这样:
values_table
___________________________________
| id | col | row | value |
-----------------------------------
| 1 | 1 | 1 | Test1 |
| 2 | 2 | 1 | Test2 |
| 3 | 1 | 2 | Test3 |
| 3 | 3 | 2 | Test4 |
| 3 | 4 | 3 | Test5 |
-----------------------------------
我想达到以下结果:
_________________________________
| col_1 | col_2 | col_3 | col_4 |
---------------------------------
| Test1 | Test2 | null | null |
| Test3 | null | Test4 | null |
| null | null | null | Test5 |
---------------------------------
我不知道它可能有多少列,所以它必须是动态的,而不是像静态左连接。这样的事情可能吗?
如果有人可以帮助我,将不胜感激!
谢谢!
解决方案
推荐阅读
- google-dfp - 使用 Google 广告管理器的插页式广告
- docusignapi - DocuSign - 无法转换文档
- r - R:测试数据框中名称值的重叠
- css - 折叠后导航栏标题变为垂直
- c# - 如何在 dotnet core 3 控制台应用程序中更改时重新加载“appsettings.json”
- java - 在线程中运行的信号量任务
- swift - 为什么这个 SwiftUI Picker 代码不起作用?
- kotlin - 游标获得的arraylist元素的总和
- python - 在 XML 中解析具有命名空间的根节点的属性
- jquery - 我无法使用此代码在单击时更改类背景颜色。为什么?