如SQL Server 2000中可以這樣實現更新或刪除記錄
update t1 from t1 a,t2 b
set a.fd = 1 where a.id = b.id and b.fd2 = 'a' and b.fd3 = 'b' and b.fd4 = 'c' delete t1 from t1 a,t2 b
where a.id = b.id and b.fd2 = 'a' and b.fd3 = 'b' and b.fd4 = 'c' 以上兩句在Oracle中如何實現呢,想了很久了,請高手幫助,謝謝

解决方案 »

  1.   

    delete t1 
    where t1.id 
    in( select b.id from t1 a, t2 b 
    where 
    b.id  = a.id and 
    b.fd2 = 'a' and 
    b.fd3 = 'b' and 
    b.fd4 = 'c' )
      

  2.   

    換一個復雜的條件,怎麼實現呢,謝謝
    delete t1 from t1 a,(Select a.id1,b.id2,c.id3 
    from a,b,c where a.id = b.id and b.id2 = c.id2) b
    where a.id1 = b.id1 and a.id2 = b.id2 and a.id3 = b.id3
    and b.fd2 = 'a' and b.fd3 = 'b' and b.fd4 = 'c'
      

  3.   

    更正一下,謝謝
    delete t1 from t1 a,(Select a.id1,b.id2
    from a,b,c where a.id = b.id and b.id2 = c.id2
    where b.fd2 = 'a' and b.fd3 = 'b' and b.fd4 = 'c'
    ) b
    where a.id1 = b.id1 and a.id2 = b.id2 and a.id3 = b.id3
      

  4.   

    不好意思,上面寫的還是有問題,請將以下T-SQL轉換為PL/SQL
    delete t1 from t1 a,t2 b
    where a.fd1 = b.fd1 and a.fd2 = b.fd2 and b.fd3 = 'abc'
      

  5.   

    delete from t1 a
    where exists (select 1 from t2 b  where a.fd1 = b.fd1 and a.fd2 = b.fd2 and b.fd3 = 'abc'
    )