a表中与b表不一样的数据:
select * from a where not exists(select * from b where 工号=a.工号)b表中与a表不一样的数据:
select * from b where not exists(select * from a where 工号=b.工号)

解决方案 »

  1.   

    把a表与b表不一样的数据提取出来select *  from  a inner join b on a.工号<>b.工号
      

  2.   

    ----或者
    select *  from  a , b where a.工号<>b.工号
      

  3.   

    如这两个表,1个是.dbf 数据库 另一个是.mdb数据库应该怎么处理呀 
      

  4.   

    SELECT a.*
    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
       'c:\MSOffice\Access\Samples\northwind.mdb';'admin';'mypwd', Orders) 
       AS a where not exists(select * from b where 工号=a.工号) 
    union
    select * from b where not exists(SELECT a.*
    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
       'c:\MSOffice\Access\Samples\northwind.mdb';'admin';'mypwd', Orders) 
       AS a where 工号=b.工号)
      

  5.   

    a表中与b表不一样的数据:
    select * from 
    openrowset('Microsoft.Jet.OLEDB.4.0','x:\A.mdb';'admin';'',a) a
     where not exists(select * from openrowset('MSDASQL',
    'Driver=Microsoft Visual FoxPro Driver;
    SourceDB=e:\VFP98\data;SourceType=DBF','select * from b') b where 工号=a.工号)b表中与a表不一样的数据:
    select * from openrowset('MSDASQL','Driver=Microsoft Visual FoxPro Driver;
    SourceDB=e:\VFP98\data;SourceType=DBF','select * from b') b
     where not exists(select * from openrowset('Microsoft.Jet.OLEDB.4.0',
    'x:\A.mdb';'admin';'',a) a  where 工号=b.工号)
      

  6.   

    select * from a where not exists(select * from b where 工号=a.工号)
    union
    select * from b where not exists(select * from a where 工号=b.工号)