表A
id name
-------------
1 tom
2
3 nick
4 lucy
表B
id class
-------------
2 a1
2 c3
4 d2表C
id sex
-------------
1 F
2 M
4 F
4 F想要的结果
id name class sex
1 tom F
2 cat a1 M
2 cat c3
3 nick
4 lucy d2 F
4 F就是三个表的连接
用oracle
id name
-------------
1 tom
2
3 nick
4 lucy
表B
id class
-------------
2 a1
2 c3
4 d2表C
id sex
-------------
1 F
2 M
4 F
4 F想要的结果
id name class sex
1 tom F
2 cat a1 M
2 cat c3
3 nick
4 lucy d2 F
4 F就是三个表的连接
用oracle
解决方案 »
- 问下 sequence 的问题
- oracle中函数中可以使用group by 吗?
- 索引影响查询效率的问题
- 急!!这样SQL如何写?在线等!!!!
- Oracle Directory manager 使用疑问 Oracle10g
- Oracle安装,郁闷中。。。
- 谁用过oracle的oo4o code wizard?--救命啊
- 初学ORACLE,推荐本好点的入门书吧
- 求救: 今天公司的服务器 重装系统,但是漏备份了一个oracle 数据库中的一个用户,现在原oracle的文件夹还在的,还能抽取出来我要的那个用户吗?
- oracle多行合并成一行,并且行内不同值组成新列。显示在同一行
- oracle 数据库 某个表隔一段时间某名奇妙的丢失数据
- oracle数据库连接问题
from a
left outer join b on a.id = b.id
left outer join c on a.id = c.id
from a,b,c
where a.id=b.id and a.id=c.id
A.ID=B.ID(+)
AND A.ID=C.ID(+)
happy84911的这位朋友的最接近
可是还是会出现迪卡尔连接
select
id,decode(mm,1,name,'')name,decode(mm,1,class,'')class,(case when ll<=mm then sex else '' end) sex
from
(
select id,name,class,sex,nn,
row_number() over(partition by id,nn order by id) ll,mm
from
(
select a.id id,name,class,sex,nn,row_number() over(partition by name,class order by id) mm from a left outer join b on a.id = b.id
full join (select c.*,row_number() over(partition by c.id order by c.id)nn from c )c on a.id=c.id order by a.id)
)
--result:1 tom F
2 cat a1 M
2 cat c3
3 nick
4 lucy d2 F
4 F