select 姓名 from A表 where 姓名 not in(select 姓名 from B表)
union
select 姓名 from B表 where 姓名 not in(select 姓名 from A表)

解决方案 »

  1.   

    假设a表中含有b表中不存在的数据,这时你可以这样查询:select a.* ,b.* from stud1 a left join stud2 b on a.name=b.name where b.name is null 假设b表中含有a表中不存在的数据,这时你可以这样查询:select a.* ,b.* from stud1 a left join stud2 b on a.name=b.name where a.name is null 
      

  2.   

    select * from A表 a where not exists(select 姓名 from B表 b where b.姓名=a.姓名)
    union
    select * from B表 b where 姓名 not in(select 姓名 from A表 a where b.姓名=a.姓名)
      

  3.   

    不好意思写错了select * from A表 a where not exists(select 姓名 from B表 b where b.姓名=a.姓名)
    union
    select * from B表 b where not exists(select 姓名 from A表 a where b.姓名=a.姓名)