select id,num from a outer join b on a.id=b.id
  where id not in (select id from a inner join b on a.id=b.id and a.num=b.num)

解决方案 »

  1.   

    --tryselect A.*
    from 表A A
    where exists (select 1 from B表 where A.id<>B.Id)
    union all
    select A.*
    from 表A A 
    where exists (select 1 from B表 B where A.id=B.id and A.num<>B.num)
      

  2.   

    zlp321002(好好学习,贴贴向上) 
    請問;select 1  啥意思.
      

  3.   

    这样应该比较清楚一点:
    select a.id, a.num
    from a left join b on a.id=b.id
    where b.id is null
    union all
    select b.id, b.num
    from a right join b on a.id=b.id
    where a.id is null
    union all
    select a.id, a.num
    from a inner join b on a.id=b.id and a.num<>b.num
      

  4.   


    select B.* 
    from 
       B 
    where B.id not in(select id from A)
    union all
    select A.* 
    from 
       A 
    where A.id not in(select id from B)
    union 
    select A.* 
    from
       A,B
    where  A.id=B.id and A.num<>B.num
      

  5.   

    SELECT * FROM A
    WHERE ID NOT IN (SELECT ID FROM B)
    UNION ALL
    SELECT * FROM B
    WHERE ID NOT IN (SELECT ID FROM A)SELECT * FROM A 
    LEFT JOIN B ON A.ID=B.ID AND A.NUM<>B.NUM