假设我们有这张表:
CREATE TABLE `table1` (
`Name` CHAR(50) NOT NULL,
`Type` CHAR(50) NOT NULL,
`Value` DOUBLE NOT NULL
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;
---------------------------------
| Name | Type | Value |
---------------------------------
| Dep1 | Cash | 100 |
---------------------------------
| Dep1 | Card | 200 |
---------------------------------
| Dep2 | Cash | 300 |
---------------------------------
| Dep2 | Card | 400 |
---------------------------------
如何创建MySQL select查询来转换像这样的列中的行? 我必须提到“名称”列有动态值!
--------------------------------
| Name | Cash | Card |
--------------------------------
| Dep1 | 100 | 200 |
--------------------------------
| Dep2 | 300 | 400 |
--------------------------------