易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL查询问题(oracle) - Oracle / 开发

如下2张表:
table1:
node_id
parent_id
root_id
value

table2:
node_id
status

表1存储了一棵树,表2存储了节点状态,问题如下:

如何用SQL语句获得状态status为1的节点的所有子节点以及其下子树中所有节点的value?

求解。由于客观因素只能用sql实现,不然就递归了。。。多谢大家

select a.node_id,a.value
from table1 a,table2 b
where a.node_id=b.node_id
start with b.status=1
connect by prior a.node_id=a.parent_id

UP,这个需要用到 start...wiht connect by 语法,层次查询。
引用
select a.node_id,a.value
from table1 a,table2 b
where a.node_id=b.node_id
start with b.status=1
connect by prior a.node_id=a.parent_id


引用
select a.node_id,a.value
from table1 a,table2 b
where a.node_id=b.node_id
start with b.status=1
connect by prior a.node_id=a.parent_id


多谢回复!不过报 sql command not properly ended 错误,试了很多顺序还是不行,望解答,谢谢了

SQL code:

create table tb(id int,pid int);
insert into tb select 1,0 from dual;
insert into tb select 2,0 from dual;
insert into tb select 3,1 from dual;
insert into tb select 4,1 from dual;
insert into tb select 5,3 from dual;
create table tc(id int,statu


相关问答:

oracle 10g web登陆EM的问题? - Oracle / 基础和管理

安装了Oracle 10g,默认安装了orcl数据库,这个数据库能不能删除啊,还有我如果新建了其他数据库,怎么知道在web中登陆不同数据库的地址啊?

1
可以删除
2
在WEB地址栏中输入地址的时候指定新创建的数据库的IP ......

oracle数据库 缓冲池 - Oracle / 基础和管理

请问这个缓冲池是怎么回事啊?可以连接缓冲池利用其中的数据吧?怎么用?
这个是oracle自动做的,一般应用程序是操作不了的。

不能直接连接吗?

引用
不能直接连接吗?
不能

那缓冲池里的数据也不能查询 ......

java怎么连接Oracle,急啊 - Java / Java相关

private static final String URL = "jdbc:oracle:thin:@localhost:1521:orcl";
private static final String USERNAME = "sys";
private static final String PASSWORD = "s ......

求一sql【谢谢】 - MS-SQL Server / 基础类

需求如下:
a表:
 p_id status  
  1 0
  2 0
b表
rec_id pid purchase_qty receive_qty flag
1 1 10 10 0
2 ......

linux下C语言开发oracle的问题。

两个文件1.PC,1.inc
1.PC有操作oracle数据库的 ,1.inc也有操作oracle数据库 
在其他数据中如informix 中$include 1.inc就可以使用了
在ORACLE数据库重 $include 1.inc不可用 EXEC SQL include 1.inc也不可 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号