Oracle多表查询之minus

select * from A minus select * from B

*****************************
返回A表中A B不相同的部分。

SQL> select * from test001;

NAME
----------
1
2
3
4
5

SQL> select * from test002;

NAME
----------
4
5
6
7
8

SQL> select * from test001 minus select * from test002;

NAME
----------
1
2
3

SQL> select * from test001 union select * from test002;

NAME
----------
1
2
3
4
5
6
7
8

按照上面的结果,查询ab交集只需要
select * from A minus (select * from A minus select * from B);

SQL> select * from test001 minus (select * from test001 minus select * from test002);

NAME
----------
4
5

posted on 2011-09-05 14:57  KevinHuke  阅读(176)  评论(0编辑  收藏  举报