既然是主从表,那就应该有个字段关联。比如:序号(no)
select a.*,b.*,c.* from a a,b b ,c c
where a.no = b.no and a.no = c.no;
select a.*,b.*,c.* from a a,b b ,c c
where a.no = b.no and a.no = c.no;
解决方案 »
- MAC OS 如何安装tns麻烦各位告诉我方法,装了3天Oracle都没成功
- oracle security management
- 求助,ORACLE存储过程~动态SQL
- 急 数据库管理 !!!
- oracle9i, order by语句问题
- 操作系统是 windows xp 可不可以安装oracle816版本
- 我看资料,这两个语句都是查表空间的大小,查出来相差怎么那么大呢?哪个更准确?
- 这个表是做什么用(菜鸟问题)?
- 求助贴,下面这个游标怎么都运行不出来,还请各位大神帮忙指导下,拜谢!
- 新手求教WIN8.1装oracle 11g 碰到问题
- 向高手求教!(关于SELECT语句)
- 请各位快帮帮忙?
inner join c on a.no=c.no
select a.*,b.*,c.* from a a,b b ,c c
where a.主键 = b.引用a的主键 and a.主键 = c.引用a的主键;
如:
a表
no name id
1 steven 1111
2 tom 2222b表
b_no a_no re
1 1 aaaaa
2 1 bbbbbc表
c_no a_no thing
1 1 cccccc
2 1 dddddd要一条语句,实现在结果如下:1 steven 111 aaaaa bbbbb ccccc ddddd
select a.no,a.name,a.id,
decode(b.re,'aaaaa',b.re) aaaaa,
decode(b.re,'bbbbb',b.re) bbbbb,
decode(c.thing,'ccccc',b.thing) ccccc,
decode(c.thing,'ddddd',b.thing) ddddd
from a,b,c
where a.no=b.a_no and a.no=c.a_no
decode(b.a_no,a.no,b.re) aaaaa,
decode(c.a_no,a.no,c.thing) ddddd
from a,b,c
where a.no=b.a_no and a.no=c.a_no
select no,name,
max( decode( a_no, no, re, null ) ) no_10,
max( decode( a_no, no, re, null ) ) no_20,
.....
max( decode( a_no, no, thing, null ) ) no_30,
max( decode( a_no, no, thing, null ) ) no_40,
....
from a,b,c
where a.no=b.a_no(+) and a.no=c.a_no(+)
group by no,name