select * from a
union
select * from b
where license_id not in(
      select license_id from a
)

解决方案 »

  1.   

    select * from a
    Union 
    select * from b
      

  2.   

    union本身就可以消除相同项,除非用UNION ALL。
      

  3.   

    union 只能过滤完全相同的记录,但是楼主上面的有可能 license_id 相同,但是假如其他的不同,这样就不能过滤了
      

  4.   

    表的其他字段结构都相同?
    union是联合两个结构完全相同的表的 
    select * from a 
    union
    select * from b
    where x not in(select b.x from b inner join a on a.x=b.x)
      

  5.   

    phantomMan
    -____-
    你做什么的 大清早的就来抢分 让我怎么活  55555
      

  6.   

    phantomMan(去年Delphi,年底.net,今年5月SQL,现在XML,马上Socket.) 是对的
      

  7.   

    select DISTINCT * from (select * from a
    union all
    select * from b) C
      

  8.   

    summerICEREDTEA(过年前争取上星 :)) :告诉你吧,phantomman是一个专业的回答问题的人士!他天天都在线的!呵呵!抢分你是抢不过他的!^_^!