内容如下:
1.
select * from (
select distinct t.g3e_tno,t.g3e_cost,t.g3e_fid,t.g3e_sourcefid,t.g3e_fno,c.cd_xw
from copytf t,connectivity_n c where t.g3e_tno=582
and exists (select c.g3e_fid from connectivity_n c where c.g3e_fid = t.g3e_fid) v) 
connect by prior v.g3e_fid=v.g3e_sourcefid start with v.g3e_cost=0
查询出来得出一个结果2. create view cv_t as select distinct t.g3e_tno,t.g3e_cost,t.g3e_fid,t.g3e_sourcefid,t.g3e_fno,c.cd_xw
from copytf t,connectivity_n c where t.g3e_tno=582
and exists (select c.g3e_fid from connectivity_n c where c.g3e_fid = t.g3e_fid)select * from cv_t connect by prior v.g3e_fid=v.g3e_sourcefid start with v.g3e_cost=0查询出来又是一个结果,难道先建立视图和在查询语句中建立视图不一样么?
 2 的结果是对的。我想问一下:这两个方法到底有什么不同啊,为什么会结果不一样呢?
要怎么修改1,让他和2执行结果是一样的

解决方案 »

  1.   

    楼主的SQL有问题吧。
    select distinct t.g3e_tno,t.g3e_cost,t.g3e_fid,t.g3e_sourcefid,t.g3e_fno,c.cd_xw
        from copytf t, connectivity_n c
        where t.g3e_tno=582
          and exists (select c.g3e_fid from connectivity_n c where c.g3e_fid = t.g3e_fid)
    是否应该改成
    select distinct t.g3e_tno,t.g3e_cost,t.g3e_fid,t.g3e_sourcefid,t.g3e_fno,c.cd_xw
        from copytf t, connectivity_n c
        where t.g3e_tno=582
          and c.g3e_fid = t.g3e_fid