有两个数据库acc1、acc2,都存有多条数据。现在想显示acc2中有但是acc1中没有的数据,而且acc2中数据可能有多条重复。同时显示在dbgrid中,如何显示?
因为是ACCESS数据库,子查询不能返回多个值。所以用
select * from acc2 where not exists (select * from acc1)。这个查询不能做到。acc2的字段acc1全部都有。但acc1还有一些acc2没有的字段。
部分字段相同,能否实现?

解决方案 »

  1.   

    那些字段没有啊?
    比如一个关键字段ID
    select * from acc2 where ID not exists (select ID from acc1)
    使用这样的语句才行。
      

  2.   

    是不是数据库的语法问题?select * from acc2 where not (ID exists (select ID from acc1));select * from acc2 where ID Not in (select ID from acc1));
      

  3.   

    不是语法错误。好像不能这么用。在ACCESS中可以这样用吗?
      

  4.   

    select * from acc2 where not exists (select * from acc1 where acc2.field1 = acc1.field1 and acc2.field2 = acc1.field2 )