select
(
select count(*) from wcmchnldoc where docchannel in
(
select d.channelid from wcmchannel d start with d.channelid in (c.channelid) CONNECT BY d.parentid = PRIOR d.channelid
)
) x
from wcmchannel c where channelid=1326这个子查询的执行结果一直都出不来请问哪里有问题吗?
我如果直接
select count(*) from wcmchnldoc where docchannel in
(
select d.channelid from wcmchannel d start with d.channelid in (1326) CONNECT BY d.parentid = PRIOR d.channelid
)
这样写结果是很快能出来
可是跟上面的意思不是一样的吗?
是因为不能套两层的原因吗?
请高手解释!
(
select count(*) from wcmchnldoc where docchannel in
(
select d.channelid from wcmchannel d start with d.channelid in (c.channelid) CONNECT BY d.parentid = PRIOR d.channelid
)
) x
from wcmchannel c where channelid=1326这个子查询的执行结果一直都出不来请问哪里有问题吗?
我如果直接
select count(*) from wcmchnldoc where docchannel in
(
select d.channelid from wcmchannel d start with d.channelid in (1326) CONNECT BY d.parentid = PRIOR d.channelid
)
这样写结果是很快能出来
可是跟上面的意思不是一样的吗?
是因为不能套两层的原因吗?
请高手解释!
(
select count(*) from wcmchnldoc where docchannel in
(
select d.channelid from wcmchannel d start with d.channelid in (c.channelid) CONNECT BY d.parentid = PRIOR d.channelid
)
) x
from wcmchannel c where channelid=1326
你这样写不会报错??
你是把x的查询结果作为检索字段了
而x的子查询如果返回的是一个固定的值那倒还可以检索出来,,因为可以把它当常量来处理
再说了,你select 中的字段是要从from wcmchannel 这个表来的,很显然你的子查询X(临时表)和它不搭干。
select
(
select count(*) from wcmchnldoc where docchannel in
(
select d.channelid from wcmchannel d start with d.channelid in (c.channelid) //这个是wcmchannel 的值,我下面是parentid=?,现在改channelid为1316
这个c.channelid也是131了,可是就是查询不出,不是查询速度的问题,我直接查这 个子查询是可以的;
CONNECT BY d.parentid = PRIOR d.channelid
)
) x
from wcmchannel c where channelid=1326//parentid=?而且count(*) 我这是统计出来的数据,是一个chilid返回的一行记录怎么会报错
(
select d.channelid from wcmchannel d start with d.channelid in (c.channelid) CONNECT BY d.parentid = PRIOR d.channelid
)这个结果是个常量!
where channelid=1326这个又指定了具体的ID,两项矛盾啊。
就类似于:select 5 from table t where t.id=1;
(
select count(*) from wcmchnldoc,wcmchannel c where c.channelid=1326
and docchannel in
(
select d.channelid from wcmchannel d start with d.channelid in (c.channelid) CONNECT BY d.parentid = PRIOR d.channelid
))
from dual 你这样写试试
这个id(原本是一个栏目的ID)下的的下一级栏目的的文章总数,
如这样
栏目1(传入的栏目ID)(父)
栏目 1.1(子)
栏目 1.1.1(子子)
栏目1.1.1 (子子子)他的子栏目是一定的可能还有子栏(用户自己可能新新增)
栏目 1.2(子)
栏目 1.3(子)
现在要统计他的子栏目的下的所有栏目的文章总数 ,即统计栏目 1.1(子)同级的文章总数
那要怎么写,
上面的语句只能统计到自己下级的所有栏目的文章总数,
如果这样
select d.channelid from wcmchannel d start with d.channelid in (?) CONNECT BY d.parentid = PRIOR d.channelid
我只要把这个值传入就行了