有2个表
表first
id number,
a number,
b number,
c number表second
aa number,
bb number,
cc number现在我想删除表first中的数据,条件是a=aa and b=bb and c=cc,只有同时满足这3条才删除这个可执行的sql语句怎么写?最后是放在oracle存储过程中执行的

解决方案 »

  1.   

    delete from first x
          where exists(
                       select 1 
                         from second y
                        where x.a = y.aa
                          and x.b = y.bb
                          and x.c = y.cc
                          and rownum = 1           --加上rownum =1是为了效率,这样效率可能高,也可会降低
                       );
      

  2.   

    delete from first f where exists(select 1 from second s where f.a=s.aa and f.b=s.bb and f.c=s.cc);
      

  3.   


    delete from first a
      where exists (select 1 from second b where a.a=b.aa and a.b=b.bb and c.c=c.cc);