学习oracle技术,每天学一点,每天进步一点
exists 的问题
上一篇 /
下一篇 2008-01-08 17:22:34
/ 个人分类:pl/sql
今天同事发以下两个sql来问我,怎么运行结果一样
Select Id
*y8Nk#fMia U0 From Tb_Admin_RoleITPUB个人空间l8V"y1Wj'i
Where Exists (Select Id From Tb_Admin_Role Connect By Prior Id = Parent_Id Start With Id = 222);ITPUB个人空间-^G[E,HD yf^
8l|Rr] |0Select IdITPUB个人空间s;hm,W?Gm.P}
From Tb_Admin_Role
_
U(@)hp/e1kl:Ci`0 Where Exists (Select Id From Tb_Admin_Role Connect By Prior Id = Parent_Id Start With Id = 1);
一看,写法有问题
这样写才是对的,两表之间ID必须关联
Select IdITPUB个人空间 p,I5c^!dx\
From Tb_Admin_Role a
2A`$],O.K0 Where Exists (Select Id From Tb_Admin_Role b where a.id=b.id Connect By Prior Id = Parent_Id Start With Id = 222);ITPUB个人空间+z5esd;jw!DN
XNb$} y0Select Id
_
[)T!vTx"g8A:RcX5B0 From Tb_Admin_Role aITPUB个人空间hV$cUQz"F
Where Exists (Select Id From Tb_Admin_Role b where a.id=b.id Connect By Prior Id = Parent_Id Start With Id = 1);
其实上面这个
Select IdITPUB个人空间M/T%\?F8M
From Tb_Admin_Role a
i(f["]0l2`;r
E
c+D'q"H3I0 Where Exists (Select Id From Tb_Admin_Role b where a.id=b.id Connect By Prior Id = Parent_Id Start With Id = 222);
S!v3x%ez2EO0
就等价于
Select Id From Tb_Admin_Role Connect By Prior Id = Parent_Id Start With Id = 222
前面是画蛇添足了,呵呵
导入论坛
引用链接
收藏
分享给好友
推荐到圈子
管理
举报
TAG: