Sele_where := '';
//条件1
if Condition1 <> '' then
Begin
if Sele_Where <> '' then
Sele_Where := Sele_Where + ' and ';
Sele_where := sele_where + 'Field1 = Condition1';
end;
...
//条件X
if ConditionX <> '' then
Begin
if Sele_Where <> '' then
Sele_Where := Sele_Where + ' and ';
Sele_where := sele_where + 'FieldX = ConditionX';
end;
if Sele_Where <> '' then
Sele_SQL := 'select * from table1' + ' where ' + Sele_Where
else
Sele_SQL := 'select * from table1';
With Query1 do
Begin
Close;
SQL.Clear;
SQL.Add(Sele_SQL);
Open;
end;