Adoquery 的Sql语句 “select * from table where ....” 得到数据,用Grid 显示出来现在 Adoquery 的Sql语句 “select * from table where ....”中where 后面发生了变化,得到另外的一组数据,
我要与以前查出来的数据一同显示在Grid 中请问如何做,谢谢!

解决方案 »

  1.   

    SELECT *
    FROM (SELECT *
            FROM table1
            UNION ALL
            SELECT *
            FROM table2) DERIVEDTBL
      

  2.   

    多谢oloveuxyz的回复!
    我查询的是同一个表,只是判断条件不一样。有可能有无数次查询,我要求所查出来的结果全部同时透过Grid 显示出!
      

  3.   

    SELECT *
    FROM (SELECT top 5 *
      FROM table1
      UNION ALL
      SELECT top 10 *
      FROM table1) DERIVEDTBL一共显示15条,里面的条件按照自己的要求来写啊
      

  4.   

    晕~~ 你加个临表,所有数据插到临表,读临表就行啦~~或都用一个CDS或普通GRID也行
      

  5.   

    我提供3个方法:
    1.直接用程序代码实现:procedure TRES_CQ_JBPG_F.cxButton2Click(Sender: TObject);
    begin
      inherited;
      if (Trim(cx_accountid.Text)='') then
      begin
        MessageDlg('請檢查:查詢的工號不能為空!',mtWarning,[mbOK],0);
        cx_accountid.SetFocus;
        Exit;
      end;
      if (Trim(cx_accountid.Text)<>'') then
      begin
        if Trim(StrWhere)='' then
          StrWhere:= 'where Account_Id='+quotedstr(Trim(cx_accountid.Text))
        else
          StrWhere:=StrWhere+' or Account_Id='+quotedstr(Trim(cx_accountid.Text));
        qry_hr.Close;
        qry_hr.SQL.Clear;
        qry_hr.SQL.Add('select * from Res_User_Temp '+StrWhere+' Order by OpDt desc');
        qry_hr.Open;
        cx_accountid.SetFocus;
        cx_accountid.SelectAll;
        if qry_hr.RecordCount=0 then
        begin
          MessageDlg('請注意:沒有找到工號為"'''+ Trim(cx_accountid.Text)+'''"的人員資料!請與人資或資訊聯繫處理!!!',mtWarning,[mbOK],0);
          cx_accountid.SetFocus;
          Exit;
        end;
      end;
    end;2.用临时表,将数据插到表后再读出查询;
    3.用SQL同表的UNION ALL关联方法。。