select id 
from tableA full join tableB on a.id=b.id 
where a.id is null or b.id is null

解决方案 »

  1.   

    或者:
    select id
    from 
        ( select distinct id from tableA
          union all
          select distinct id from tabelB
        ) a
    group by id
    having count(*)=1
      

  2.   

    select a.id 
    from 表1 a full join 表2 b on a.id=b.id 
    where a.id is null or b.id is null
    --或
    select id from 表2 a where not exists(select 1 from from 表1 where a.id = id)
      

  3.   

    select * from 2 where id not (select id from 1 )
      

  4.   

    select a.id 
    from 表1 a full join 表2 b on a.id=b.id 
    where a.id is null or b.id is null
      

  5.   

    create table a1(a int)create table a2(a int)insert a1
    select 1
    union select 2
    union select 3
    union select 5
    union select 6insert a2
    select 1
    union select 2
    union select 3
    union select 4
    union select 6
    union select 7
    select * from a1 where a not in (select * from a2)
    union select * from a2 where a not in (select * from a1)