iteye_2177 2009-10-11 08:23
浏览 245
已采纳

一条不理解SQL语句,查询树

SELECT a.org_id, a.org_name
FROM org a
WHERE a.org_parentid = 1
AND ((a.org_id in
(select org_id
from user_org
where user_id in (select user_.user_id
from user_, user_role, wf_step_role
where wf_step_role.role_id = user_role.role_id
and user_role.user_id = user_.user_id
and wf_step_role.step_id = 2))) OR
(SELECT COUNT(*)
FROM org b
WHERE b.org_id in
(select org_id
from user_org
where user_id in
(select user_.user_id
from user_, user_role, wf_step_role
where wf_step_role.role_id = user_role.role_id
and user_role.user_id = user_.user_id
and wf_step_role.step_id = 2))
and rownum < 2
START WITH b.org_id = a.org_id
CONNECT BY PRIOR b.org_id = b.org_parentid) > 0)
order by org_order

在OR后面的不是true就是False
请解释一下这条SQL意思,详细说明一下!

  • 写回答

3条回答 默认 最新

  • wanghaolovezlq 2009-10-11 08:28
    关注

    or是短路操作嘛

    如果or的左边是true,那就不对右边进行查询了,
    如果or的左边是false,才对右边进行查询,

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?