多表列合并
来源:互联网 发布:mac 音乐剪辑合成软件 编辑:程序博客网 时间:2024/04/29 03:15
create table A(a varchar(50))create table B(b varchar(50))create table C(c varchar(50))create table D(d varchar(50),e varchar(50) ) INSERT INTO A VALUES('a1') INSERT INTO A VALUES('a2') INSERT INTO A VALUES('a3') INSERT INTO A VALUES('a4') INSERT INTO A VALUES('a5') INSERT INTO B VALUES('b1')INSERT INTO B VALUES('b2')INSERT INTO B VALUES('b3')INSERT INTO B VALUES('b4')INSERT INTO B VALUES('b5')INSERT INTO C VALUES('c1')INSERT INTO C VALUES('c2')INSERT INTO C VALUES('c3')INSERT INTO C VALUES('c4')INSERT INTO C VALUES('c5') INSERT INTO D VALUES('d1','e1') INSERT INTO D VALUES('d2','e2') INSERT INTO D VALUES('d3','e3') INSERT INTO D VALUES('d4','e4') INSERT INTO D VALUES('d5','e5') select * from A select * from Bselect * from Cselect * from D
a
--------------------------------------------------
a1
a2
a3
a4
a5
(5 行受影响)
b
--------------------------------------------------
b1
b2
b3
b4
b5
(5 行受影响)
c
--------------------------------------------------
c1
c2
c3
c4
c5
(5 行受影响)
d e
-------------------------------------------------- --------------------------------------------------
d1 e1
d2 e2
d3 e3
d4 e4
d5 e5
(5 行受影响)
selectmax(case a when 'a1' then a else '' end )as 'one',max(case b when 'b1' then b else '' end )as 'two',max(case c when 'c1' then c else '' end )as 'thre' ,max(case d when 'd1' then d else '' end )as 'four' ,max(case e when 'e1' then e else '' end )as 'six' from A,B,C,Dunion selectmax(case a when 'a2' then a else '' end )as 'one',max(case b when 'b2' then b else '' end )as 'two',max(case c when 'c2' then c else '' end )as 'thre' ,max(case d when 'd2' then d else '' end )as 'four' ,max(case e when 'e2' then e else '' end )as 'six' from A,B,C,D unionselectmax(case a when 'a3' then a else '' end )as 'one',max(case b when 'b3' then b else '' end )as 'two',max(case c when 'c3' then c else '' end )as 'thre' ,max(case d when 'd3' then d else '' end )as 'four' ,max(case e when 'e3' then e else '' end )as 'six' from A,B,C,D unionselectmax(case a when 'a4' then a else '' end )as 'one',max(case b when 'b4' then b else '' end )as 'two',max(case c when 'c4' then c else '' end )as 'thre' ,max(case d when 'd4' then d else '' end )as 'four' ,max(case e when 'e4' then e else '' end )as 'six' from A,B,C,Dunionselectmax(case a when 'a5' then a else '' end )as 'one',max(case b when 'b5' then b else '' end )as 'two',max(case c when 'c5' then c else '' end )as 'thre' ,max(case d when 'd5' then d else '' end )as 'four' ,max(case e when 'e5' then e else '' end )as 'six' from A,B,C,D
one two thre four six
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------------------------------------------
a1 b1 c1 d1 e1
a2 b2 c2 d2 e2
a3 b3 c3 d3 e3
a4 b4 c4 d4 e4
a5 b5 c5 d5 e5
(5 行受影响)
- 多表列合并
- 如何实现多表列合并
- mysql必知必会--第一回 检索单个表列 多个表列
- DataGridView控件点击表列头进行多列关联排序
- 锁定表列
- 表列名
- 表列操作
- ADO.NET表列映射
- rails 修改表列名
- 修改sde表列长度
- 内表列值相加
- 查找表列的信息
- rails 修改表列名
- MYSQL 查询表列数
- 固定表头和表列
- 固定表头和表列
- PowerDesigner表列命名
- cx_Oracle获取表列名
- ob_get_contents();ob_end_clean();ob_start();的具体用法
- Delphi接口的底层实现
- (转)被误解的C++ 之 优化variant实现
- 2011年最受投资者青睐的13家互联网初创公司
- 阻塞式TCP 接收方式
- 多表列合并
- vbox中安装ubuntu的server版
- PowerPoint2007背景怎么设置、修改以及更换
- (转)Java初学者习题20道
- DB2 在线分析处理(OLAP函数的使用)
- 仿IBM首页焦点图,缩略图大图,带文字
- orcal列修改
- C#图片压缩算法
- 远程exp、imp,以及imp时改变表空间