有两个表tab1,tab2,两表字段完全相同.tab1和tab2的主键都为列a,b,c,联合主键,int型,tab2的数据全是从tab1中抽进来的,现在要取出tab1中新增的数据,放到tab2中,示例:tab1的数据:
a b c
1 2 3
1 2 4
2 3 5
tab2的数据:
a b c
1 2 3
1 2 4
现在想要得到的结果是:
2 3 5
高手指教
a b c
1 2 3
1 2 4
2 3 5
tab2的数据:
a b c
1 2 3
1 2 4
现在想要得到的结果是:
2 3 5
高手指教
select 1 from tab2 where tab1.a = tab2.a and tab1.b=tab2.b and tab1.c = tab2.c
)
oracle还有一个交集函数,手头没有环境,你自己google一下
create table comp_b (a varchar2(2),b varchar2(2),c varchar2(2));
insert into comp_b
select '1','2','3' from dual
union all
select '1','2','4' from dual
;
commit;
select a,b,c from comp_a
minus
select a,b,c from comp_b;