根据dbgrid1.Columns[i].FieldName自己去判断. for i:=0 to dbgrid1.Columns.Count-1 do begin if dbgrid1.Columns[i].FieldName='Table1filename' then dotable1; if dbgrid1.Columns[i].FieldName='Table2filename' then dotable2; end;
同意Drate(小虫),查询的时候使用别名: select a.id as aa,b.id as bb from a,b
for i:=0 to dbgrid1.Columns.Count-1 do
begin
if dbgrid1.Columns[i].FieldName='Table1filename' then
dotable1;
if dbgrid1.Columns[i].FieldName='Table2filename' then
dotable2;
end;
select a.id as aa,b.id as bb from a,b