DELETE TABLE1.*
FROM TABLE1,TABLE2 where TABLE1.KHID = TABLE2.KHID and TABLE2.FWDWID=8

解决方案 »

  1.   

    DELETE TABLE1 where KHID in ( select KHID from table2 where  FWDWID=8)
      

  2.   

    LGQDUCKY(飘)的语句通过了,谢谢!
    不过,不知还有没有别的写法,感觉这种写法(用 in )在数据量大的时候,效率可能不高。
      

  3.   

    DELETE  TABLE1  where  exists  (  select  1  from  table2  where  and table1.khid=table2.khid and  FWDWID=8);
      

  4.   

    DELETE TABLE1 where KHID =Any(select KHID from table2 where  FWDWID=8)
      

  5.   

    谢谢诸位。用 in , exists , any 都可以通过,不知哪个效率最高。
      

  6.   

    同等条件下,推荐exists,有时要用IN,具体可以看执行计划,
      

  7.   

    DELETE TABLE1 where KHID exists ( select KHID from table2 where  FWDWID=8)
      

  8.   

    上述两个用到 exists 的 SQL 语句,哪个更好呢?
      

  9.   

    function TMainForm.GetHostInfo(header: String): String;
    var
      ServerName: String;
      ServerIni: TIniFile;
    begin
      ServerIni := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'FtpHost.ini');
      ServerName := ServerIni.ReadString('Server', header, header);
      ServerIni.Free;
      result := ServerName;
    end;