日期:2014-05-16 浏览次数:20986 次
-- 方法有2:
-- 1:用minus
select a.aid, a.aname, a.adate, a.atotal
from a
minus
select b.aid, b.aname, b.adate, b.atotal
from b;
-- 2: 用not exists
select a.aid, a.aname, a.adate, a.atotal
from a
where not exists (select 1 from b
where b.aid=a.aid
and b.aname=a.aname
and b.adate=a.adate
and b.atotal=a.atotal );
------解决方案--------------------
对楼上1进行补充
select * from a where (aid,adate) in(
select a.aid, a.adate
from a
minus
select b.aid,b.adate
from b);
------解决方案--------------------
select a.aid, a.aname, a.adate, a.atotal
from a
where a.aid not in(select b.aid from b
where b.aid=a.aid
and b.aname=a.aname
and b.adate=a.adate
and b.atotal=a.atotal );
------解决方案--------------------
习惯用not exists