删除语句
有三张表:A,B,C 其中
A字段:aId
B字段:bId
C字段:cId,aId,bId
1对多
A------>C
1对多
B------>C
现在要删除C表且知道A表的aId和B表的bId:
DELSQL:
delete from A aa,B bb,C cc where aa.aId=cc.aId and cc.cId=bb.bId and aa.aId=变量A and bb.bId = 变量B
QUERYSQL:
select * from A aa,B bb,C cc where aa.aId=cc.aId and cc.cId=bb.bId and aa.aId=变量A and bb.bId = 变量B
查询语句是可以查出一条记录的,但删除删不掉
我用的是ORACLE9.2,谢谢!!
问题点数:50、回复次数:6Top
1 楼baojianjun(包子)回复于 2005-01-14 13:12:00 得分 5
删除删不掉是什麼樣的情況
有什麼提示嗎?Top
2 楼qiaozhiwei(乔)回复于 2005-01-14 13:38:26 得分 10
delete from c
where exists (select 1 from a,b where c.aid=a.aid and c.bid= b.bid and a.aid=var_a and b.bid = var_b)Top
3 楼ORARichard(没钱的日子......)回复于 2005-01-14 14:00:17 得分 10
delete c where aid=变量A and bid=变量B;Top
4 楼fuxia(双子星)回复于 2005-01-14 14:04:19 得分 5
不明白你怎么做的??Top
5 楼snowdog19820810(雅雅)回复于 2005-01-14 14:13:59 得分 10
ORARichard(没钱的日子......)
delete c where aid=变量A and bid=变量B;
这样不就可以了么?为什么做那么麻烦呢?
Top
6 楼xojxau(sky)回复于 2005-01-14 14:14:16 得分 10
delete from c where c.aid in (select a.aid from a where a.aid=c.aid) and c.bid in (select b.bid from b where c.bid=b.bid)Top




