我有两个表,其中A表查询结果如下:编号 类型

10813 申请表
10813 登记证
10813 执照
10813 证明文件
10813 机构代码证
10827 登记证
10827 资信证明
10827 执照
10827 证明文件
10827 机构代码证B表查询结果如下:编号 类型10798 执照
10798 资信证明
10798 申请表
10798 登记证
10798 机构代码证
10798 证明文件

10803 申请表
10803 机构代码证
10803 登记证
10803 证明文件
10803 资信证明
10803 执照
我想查询编号为10803中A表和B表内容不一样的部分查询结果为:10803 资信证明 

解决方案 »

  1.   

    第一个表查询语句
    select distinct b.vender_id, a.name from qualification a, upload_file b where a.type = b.sortname and a.opening = 'Y' and b.sortname is not null order by b.vender_id第二个表的查询语句
    select c.vender_id,d.type from vender c,qualification d where d.opening='Y' and d.display='Y' order by c.vender_id其中结果集是这两个查询结构的补集
      

  2.   


    with a as(
    select 10813 id,'申请表' type from dual union all
    select 10813 id,'登记证' type from dual union all
    select 10813 id,'执照' type from dual union all
    select 10813 id,'证明文件' type from dual union all
    select 10813 id,'机构代码证' type from dual union all
    select 10827 id,'登记证' type from dual union all
    select 10827 id,'资信证明' type from dual union all
    select 10827 id,'执照' type from dual union all
    select 10827 id,'证明文件' type from dual union all
    select 10827 id,'机构代码证' type from dual
    ),
    b as(
    select 10798 id,'执照' type from dual union all
    select 10798 id,'资信证明' type from dual union all
    select 10798 id,'申请表' type from dual union all
    select 10798 id,'登记证' type from dual union all
    select 10798 id,'机构代码证' type from dual union all
    select 10798 id,'证明文件' type from dual union all
    select 10813 id,'申请表' type from dual union all
    select 10813 id,'机构代码证' type from dual union all
    select 10813 id,'登记证' type from dual union all
    select 10813 id,'证明文件' type from dual union all
    select 10813 id,'资信证明' type from dual union all
    select 10813 id,'执照' type from dual
    )
    select *
    from ((select a.id,a.type from a 
          minus
          select b.id,b.type from b)
          union all
          (select b.id,b.type from b
          minus
          select a.id,a.type from a)) t
    where id=10813;        ID TYPE
    ---------- ----------
         10813 资信证明大哥,上下2张表编号不一样,我就都改为10813,没10803了
      

  3.   

    sorry,我写复制错啦,是应该是10813
      

  4.   

    谢谢你打了那么多字,分都给你,我找到方法了,使用minus关键字 就可以查询出结果来啦。