您的索引足够多了,您是用pardox表吧,pardox支持local sql。用sql做组合查询,
实现容易,速度也不慢,delphi 自己就带local sql 的帮助。xbase系列编程的思路
应尽早放弃。多用Tquery.
with query do
begin
  close;
  sql.clear;
  sql.add('select * from table where callno=:p1 and employ=:p2 and ..');
  parambyname('p1').asinteger:=值;
  parambyname('p2').asstring:=值;
  ...
  open;
end;
具体用法请看delphi的帮助。

解决方案 »

  1.   

    如果你要排序,那就建索引;否则不用,可用SQL实现查询:
    var
      sSQL: string;
      sWhere: strng;
    begin
      sSQL := 'select * from table1';
      if Length(edtCallNo.Text)>0 then
        sWhere := 'callno='+edtCallNo.Text
      else
        sWhere := '';  if Length(edtClass.Text)>0 then
      begin
        if Length(sWhere)>0 then
          AppendStr( sWhere, ' and ' );
        AppendStr( sWhere, 'class='+edtClass.Text );
      end;  if Length(edtDepart.Text)>0 then
      begin
        if Length(sWhere)>0 then
          AppendStr( sWhere, ' and ' );
        AppendStr( sWhere, 'depart='+edtDepart.Text );
      end;  if Length(sWhere)>0 then
        AppendStr( sSQL, ' where '+sWhere );  Query1.SQL.Text := sSQL;
      Query1.Open;这里把三个字段的值都假设为整数且你的程序都检查了用户的输入。btw: 你好象键误了,employee《--》class
      

  2.   

    不必建太多索引,只对查询最频繁的字段建索引。组合查询可以可以利用SQL语句的动态拼接来实现,而且可以体现SQL语言的灵活特点,从多个表中判断组合条件,查询可以写成
    "select * from table where column1 in 
          (select column1 from table1 where ...)
          and column2 in
          (select column2 from table2 where ...)
          ......"
    把以上语句放入query中,在where 子句中传递查询条件,若没有选择此条件,就把这个where子句设为''。你可以先动态生成这个sql字符串,用MessageBox看一下,再执行查询!
      

  3.   

    太简单了,例子如下:(不需要建副索引)
    假如有三个字段callno,class,depart,分别对应Edit1、Edit2和Edit3。
    在button1的onclick事件为:
    var
     sqlstring:string;
    begin
    if edit1.text<>'' then
     begin
      sqlstring:=' callno='''+edit1.text+'''';
     end;
    if edit2.text<>'' then
     begin
       if sqlstring<>'' then
         begin
            sqlstring:='and class='''+eidt2.text+'''';
         end
       else
         begin
            sqlstring:='class='''+eidt2.text+'''';
         end; 
    if edit3.text<>'' then
     begin
       if sqlstring<>'' then
         begin
            sqlstring:='and depart='''+eidt3.text+'''';
         end
       else
         begin
            sqlstring:='depart='''+eidt3.text+'''';
         end; 
      end;  
     with query1 do
      begin
       close;
       sql.clear;
       sql.add('select * from table1 where');
       sql.add(sqlstring);
       open;
      end;end;
      

  4.   

    正如各位所说,不需建太多索引
    更简单的方法是:
    利用SQL的 LIKE 句法。假定条件中的表字段皆为字符串或整型数值。
    可创建一函数,参数为各输入框的值,返回构造的查询串。各参数为 par1,par2...parN
    在函数中判定,若某参数为空字符串,则将其值赋为'%',否则不变化
    参照ljq 的例子,但需要把 = 换成 LIKE ,给查询串赋值时赋有可能变成'%'的参数值
    当某字段为浮点数时,需转换成字符串类型。
    不好意思,我不懂delphi, 只好如此写;)