[英]Oracle insert into table2 then delete from table1, exception if fail
[英]Get rows from table1 missing in table2 oracle?
我有两个下表。 正在使用Oracle 10g
TableA
---------
id Name
--- ----
1 abc
2 def
3 xxx
4 yyy
TableB
---------
id Name
--- ----
1 abc
2 def
TableC
---------
id Name
--- ----
1 abc
2 def
现在,我需要from TableA which are not there in TableB and TableC
获取from TableA which are not there in TableB and TableC
的ID。 不使用NOT IN子句怎么办?
请帮我!
谢谢!
请试试:
SELECT
a.ID,
a.NAME
FROM
TABLEA a LEFT JOIN TABLEB b ON a.ID=b.ID
LEFT JOIN TABLEC c ON a.ID=c.ID
WHERE
b.ID IS NULL AND
c.ID IS NULL;
select * from TableA
minus
select * from TableB
编辑:
同时不在B和C中的内容:
select * from TableA
minus (
select * from TableB
intersect
select * from TableC
)
不在B或C中的:
select * from TableA
minus
select * from TableB
minus
select * from TableC
select a.id
from tableA a,tableB b,tableC c
where a.id != b.id and a.id!=c.id
这样好吗
select * from TableA
minus
(select * from TableB
union
select * from TableC)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.