繁体   English   中英

从table2中缺少table2的行中获取行?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM