ms-access - 将多列转置为 2 列
问题描述
想保留 ID,但将每个产品列转置为 1 个产品列。从
ID Product 1 Product 2 Product 3
1111 Apple Cherry Peach
2222 Apple
3333 Chery Cherry
到
ID Products
1111 Apple
1111 Cherry
1111 Peach
2222
2222
2222 Apple
3333 Chery
3333 Cherry
3333
解决方案
使用联合查询:
Select ID, [Product 1] As Products
From YourTable
Union All
Select ID, [Product 2] As Products
From YourTable
Union All
Select ID, [Product 3] As Products
From YourTable
Order By ID, Products
推荐阅读
- java - 如何从光标中删除唯一值
- speech-recognition - Python Speech_Recognition 挂断了麦克风收听
- python - 无法在编辑之前获取旧用户实例,并比较字段以进行字段编辑
- metal - 如果金属原点是左上角,为什么这张图片显示在左下角?
- php - 同步多个数据库?
- php - 如何在 laravel 播种机中获取网站网址?
- ruby-on-rails - Rails API - 没有路线匹配 [POST]
- c# - 没有给出与“Person.Person(string, string)”所需的形式参数“firstName”相对应的参数
- java - java - 如何确定骑士在Java中到达棋盘上的任何位置需要多少步
- c++ - 平均 ADC 读数在图中有奇怪的步骤