如何關聯刪除表記錄,高手請進

tommysun 2006-02-10 03:01:20
如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中如何實現呢,想了很久了,請高手幫助,謝謝
...全文
73 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoxiao1984 2006-02-11
  • 打赏
  • 举报
回复
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'
)
tommysun 2006-02-10
  • 打赏
  • 举报
回复
不好意思,上面寫的還是有問題,請將以下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'
tommysun 2006-02-10
  • 打赏
  • 举报
回复
更正一下,謝謝
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
tommysun 2006-02-10
  • 打赏
  • 举报
回复
換一個復雜的條件,怎麼實現呢,謝謝
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'
zhenjie 2006-02-10
  • 打赏
  • 举报
回复
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' )
tommysun 2006-02-10
  • 打赏
  • 举报
回复
子查詢怎麼使用呢,能否說詳細一點
zhenjie 2006-02-10
  • 打赏
  • 举报
回复
使用子查询就可以了,应该问题可以解决的。

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧