你不select成一个query再来好一点

解决方案 »

  1.   

    在此处处理
    procedure TForm1.QRDBText1Print(sender: TObject; var Value: String);
    begin
    // 处理 value就可以了,如:
       query1.close;
       query1.sql.clear;
       query1.sql.add('select aaa from at where name='+''''+value+'''');
       value :=query1.fieldbyname('aaa').asstring;
       query1.close;
    end;
      

  2.   

    按照题意:应该是使用了两个QuickRep控件
    第一个QuickRep的datasource连接一个Query1;
    控件连接好,生成报表直接预览就可以了。
    对于第二个QuickRep连接Query2
    预览时,要进行查询,后预览。
    首先,取到表1中的代码,如:
    edit1.text:='代码';
    procedure Button1Click(Sender: TObject);
    begin
    with Query2 do
    begin   
    close;
    with sql do
    begin
    clear;
    add(select * from table2);
    add('where id=:a');
    Params[0].AsString:=Edit1.Text;
    Open;
    end;
    end;   
    end;
    这只是针对于一个代码来说的,如果对于各个代码都要这样做的话,你就要使用数组和循环,自己研究一下。
      

  3.   

    用关联查询:
    例如查找table1中的id1为table2 中的id2 的值。sqltext:=select * from (select * from table1) a,(select * from table1)b where a.id1=b.id2