A、B两表结构相同,想列出A表中有而B表中没有的记录?
sql怎么写啊?谢谢!

解决方案 »

  1.   

    select * from A where not exists(select 1 from B where relationFiled1=A.relationFiled1[and relationFiled2=A.relationFiled2...and relationFiledn=A.relationFiledn]
      

  2.   

    select * from A where not exists(select 1 from B where A.col1=B.col1 and A.col2=B.col2)
      

  3.   

    select * from A where 主键字段 not in(select 主键字段 from B)
      

  4.   

    select * from A where checksum(*) not in (select checksum(*) from B)
      

  5.   

    select  * from  table_a 
    where  id no in (select id from table_b )
      

  6.   

    select * from A where id not in (select id from b)
      

  7.   

    select * 
    from A a 
    where not exists(select top 1 * from B where 主键字段=a.主键字段)