create table 新表
AS
select @i:=@i+1 as NO,NO1,NO2,NO3,MYA1 as MM
from(
select NO1,NO2,'MYA1 ' as NO3,MYA1 from 表
union all
select NO1,NO2,'MYA2 ',MYA2 from 表
union all
select NO1,NO2,'MYA3 ',MYA3 from 表
union all
select NO1,NO2,'MYA4 ',MYA4 from 表
union all
select NO1,NO2,'MYA5 ',MYA5 from 表
union all
select NO1,NO2,'MYA6 ',MYA6 from 表
)a order by NO1,NO2
select * from 新表
原表:?
1
2
3
4
5
6
7
8
9
10
11
12
表名 :user
----------------------------------------
name| course | grade
----------------------------------------
zhangsan | Java | 70
----------------------------------------
zhangsan | C++ | 80
----------------------------------------
lisi| java | 90
----------------------------------------
lisi| C#| 60
----------------------------------------
?
1
2
3
4
5
6
7
----------------------------------------
name | java | C++ | C#
----------------------------------------
zhangsan | 70 | 80 | null
----------------------------------------
lisi | 90 | null | 60
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)