for i= num1 to num2 do
begin
  FileName1='file'+IntToStr(num1);//num1为你输入的数1
  ...
  query1.sql:= 'insert into totalfiles select * from '+FileName1 
  ...
end;

解决方案 »

  1.   

    为:query1.sql.add('insert into totalfiles select * from '+FileName1 )
      

  2.   

    谢谢!如果用BacthMove控件应如何实现?
      

  3.   

    你说的是列名为file1...
    还是表名:::
    如果是列名的话,楼上的方法可行
    如果是表名的话,就用BatchMove控件来实现
      

  4.   

    table1:='file'+strtoint(trim(edit1.text));
    table3:='file'+strtoint(trim(edit3.text));
    batchmove.source:=table1;
    batchmove.destination:=table2;
    batchmove.mode:=batappendupdate;
    batchmove.source:=table3;
    batchmove.destination:=table2;
    batchmove.mode:=batappendupdate;
    try
    batchmove.excute;
    finally
    batchmove.free;
    table1.free;
    table3.free;
    end;
    如果用SQL语句如下:
    select table1.*,table3.* into table2 from table1,table3
    但是TABLE2应该是步存在的.可以通过
    rename table3 totalfiles 
      

  5.   

    AFIHA(法海) 的方法很精彩,可以对他的代码略作以下修改:
    var
      FileName1:String;
     ......
    for i= num1 to num2 do
    begin
      FileName1='file'+IntToStr(i);//num1为你输入的数1
      ....
      Query1.Close;
      Query1.SQL.Text:=
          'insert into totalfiles select * from '+FileName1; 
      Query1.ExecSQL;//每次循环把表的内容加到totalfiles里。
      ...
    end;