在2个表中有一个字段的内容大部分是一样的, 但有一个表的字段的内容肯定是另外一个表没有的,而另外一个表的那个字段内容这个表肯定有,我应该如何查出不同的记录呢?

解决方案 »

  1.   

    2000:
    select * from T1 where binary_checksum(*) not in(select binary_checksum(*) from T2)
    select * from T2 where binary_checksum(*) not in(select binary_checksum(*) from T1)
      

  2.   

    select b.*
    from a 
      left join b
     on a.col=b.col
    where b.col is null
      

  3.   

    2005
    select * from t1
    except
    select * from T2
    select * from T2
    except
    select * from T1
      

  4.   

    select *
    from table1 a
    where not exists(select 1 from table2 where a.id = id)
      

  5.   

    select * from table1 a where not exists(select 1 from table2 where col =a.col )
      

  6.   

    select *
    from tb a
    where not exists(select 1 from tb2 where id = a.id)