学习oracle技术,每天学一点,每天进步一点

exists 的问题

上一篇 / 下一篇  2008-01-08 17:22:34 / 个人分类:pl/sql

今天同事发以下两个sql来问我,怎么运行结果一样

Select Id
*y8N k#fMiaU0      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,HDyf^
           
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:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-08-30  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 15402
  • 日志数: 276
  • 图片数: 2
  • 建立时间: 2007-12-11
  • 更新时间: 2008-08-29

RSS订阅

Open Toolbar