select * from table where 1=2 的作用

printhistory.close;
  printhistory.CommandText :=
    'select * from expbill_print_hot_history where 1=2';
  try
    printhistory.Open;
  except
    on E: Exception do
    begin
      if E.Message = '网络连接异常' then
      begin
        DialogInformation(EXCEPTMESSAGE);
        exit;
      end;
    end;
  end;
  ShowProgressDlg('打印', '热敏打印', crsbillCheckedCount);

说白了,“1=2”永远不满足,所以查不到数据,这句话的作用在这里就是为了判断网络通不通,服务器有没有连接上,

一般情况下,“select * from table where 1=2”就扮演着这种角色。

我悟了。

 
 

你可能感兴趣的:(select * from table where 1=2 的作用)