有下列语句,不知错在哪里?
query1.SQL.Add('select a.企业代码,a.名称 from 企业信息表.db as a,实施情况表.db as b where 性质= '+''''+trim(combobox4.Text)+''''+' and '+'a.企业代码<>b.企业代码 ');
我的目的是想在a表中查出企业代码不在b表中所有记录(企业代码是a、b两个表共有的)。
但结果却不对,不知问题在哪?

解决方案 »

  1.   

    query1.SQL.Add('select a.企业代码,a.名称 from 企业信息表.db as a where 性质= '+''''+trim(combobox4.Text)+''''+' and '+'a.企业代码 not in (select 企业代码 from 实施情况表.db) ');
      

  2.   

    query1.SQL.Add('select a.企业代码,a.名称 from 企业信息表.db as a,实施情况表.db as b where a.性质= '+''''+trim(combobox4.Text)+''''+' and '+'a.企业代码<>b.企业代码 ');
      

  3.   

    用exists
    query1.SQL.Add('select a.企业代码,a.名称 from 企业信息表.db as a where a.性质= '''+trim(combobox4.Text)+''' and '+' not exists(select 1 from 实施情况表.db as b where a.企业代码 = b.企业代码 )');
      

  4.   

    用exists
    query1.SQL.Add('select a.企业代码,a.名称 from 企业信息表.db as a where a.性质= '''+trim(combobox4.Text)+''' and not exists(select 1 from 实施情况表.db as b where a.企业代码 = b.企业代码 )');