select * from a
union all
select * from b
 where not exists (select 'x' from a
                    where id = a.id
                      and no = a.no);

解决方案 »

  1.   

    select * from a
    union
    select * from b
      

  2.   

    select * from a
    union 
    select * from b
    where not exists (select 'x' from a
                        where b.id = a.id
                          and b.no = a.no);
    这样成功了。
      

  3.   

    select * from a
    union
    select * from b有问题,为什么啊?测试过吗?
    union可以删除重复输入项的,为什么要判断,这会极大地降低速度。
      

  4.   

    呸,原来两个表中同主键数据还有不同的,faint