insert into temp select * from temtab_dy t where t.xf + t.zsf - t.dkje - t.hjje < 0
select * from temp b inner join zc_zcb s on b.xh = s.xh where s.zcf = '否'--把temtab_dy中满足t.xf + t.zsf - t.dkje - t.hjje < 0条件的记录选入临时表temp,把temp中每条记录在zc_zcb表中对比,存在并且zcf='否'的都显示出来。如何不使用临时表temp实现呢?

解决方案 »

  1.   

    select * 
    from temtab_dy a,zc_zcb b 
    where a.xf+a.zsf-a.dkje-a.hjje < 0  and b.zcf = '否' and a.xh = b.xh
      

  2.   

    我测试了, 在oracle里 select * from table1 a ,table2 b  where  a.product_name=b.product_name  这种一样的可以, 1楼的应该是正解
      

  3.   


    SELECT *
      FROM TEMTAB_DY T, ZC_ZCB S
     WHERE T.XF + T.ZSF - T.DKJE - T.HJJE < 0
       AND T.XH = S.XH
       AND S.ZCF = '否';根据情况可能需要创建TEMTAB_DY表上的index:
    xh列index 或者 xf+zsf-dkje-hjje的函数index
      

  4.   


    select * from temtab_dy t 
    inner join zc_zcb s on t.xh = s.xh 
    where t.xf + t.zsf - t.dkje - t.hjje < 0 and s.zcf = '否' 差不多