oracle 自己表与自己表连接可以么? 可以的话,能的话给提个小例子!~万分感激!~~

如题!~~~

select a.*,b.* from table a, tabl b where a.**=b.**

起别名即可

[code="java"]select a.* from (select * from t where t.type='a') a,(select * from t where t.type='b') b
where a.pid=b.pid[/code]

还有一种方法:

[code="java"]select a.*
from t a
where a.type='a' and exists(select 1 from t b where b.type='b' and a.pid=b.pid)[/code]

不过如果 你是用来去重的话:

[code="java"]select *
from (select a.*, rownum row_num from A_TEST a) x
where x.row_num in (select min(rownum) from A_TEST t group by name)[/code]

参考URL [url]http://navylee.iteye.com/blog/801280[/url]

如果是 要递归查询的话 ,还好 Oracle 有递归的 函数:

[code="java"]select * from table connect by prior id=pid start with id=xx[/code]