select a.* 
from table1 a
where not existx (select  b.labid 
                  from table2 b
                  where a.labid = b.labid)

解决方案 »

  1.   

    是select * from table1 where labid not in 
                          (select distinct labid from table2 )吧
      

  2.   

    select * from table1 where labid not in (select labid                 from table2 )
      

  3.   

    你的那个字段肯定可以为空。
    你那句,加上限制条件即可。我习惯not exists
    呵呵,写错了。
    select a.* 
    from table1 a
    where not exists (select  b.labid 
                      from table2 b
                      where a.labid = b.labid)
      

  4.   

    clientdataset.commandtext 中可以传递复杂的sql语句
    clientdataset.commandtext = 'select * from table1 where labid not in (select labid from table2 )';
      

  5.   

    用not exists ,not in 都可以,只是你的 a.* 出错了
      

  6.   

    A.*是对的。
    select a.* from table1 where labid not in (select distinct labid                 from table2 )
    就是这样,你仔细看看,肯定没错。
      

  7.   

    问题解决,现总结如下 1。使用 a.* 是对的(ms sql server)
     
     2. 必须保证 字段名相同或者在子select 语句中使用 where 指定
      
      (在我的程序中 两个字段名不同)另:iroi 你的分宁外开帖给你