if  ..........<>'' then 
 sqlstr:='   ';
if .................<>'' then 
sqlstr:=sqlstr+  ''''''''''''''';
....................................

解决方案 »

  1.   

    嘻嘻
    Str_SQL := 'Select * from TableName where ' ;
    Str_SQL := Str_SQL + Edit1.Text + '  ' + ComboBox1.Text + ' '+ #39 + Edit2.Text + #39;//如果是字符型、时间的,就叫#39,否则不加;
    再这样循下去,但是,注意,下边就要加 And Or 等了,也用一个控件就可以;
    //Edit1.text -> 字段名;
    //ComboBox1.Text ->是逻辑条件;
    //Edit2.Text ->条件;
    Query.SQL.Add(Str_SQL);
    Query.Open;
      

  2.   

    tangyong_delphi() 老兄在吗?
    我的email:[email protected]
      

  3.   

    tangyong_delphi() 老兄在吗?
    我的email:[email protected] 谢谢!
      

  4.   

    select * from table where 字段1=:para0 and 字段2=:para1 and...query.parambyname('para0').as....:= ...query.parambyname('para1').as....:= ...
    还可以用子查询
      

  5.   

    procedure TForm1.Button32Click(Sender: TObject);
    var
    xm1,xm2,bj1,bj2,nj1,nj2:string;
    xmb,bjb,njb:boolean;
    rpt:integer;
    begin
     xm1:=edit2.text;
     bj1:=combobox3.text;
     nj1:=combobox4.text;
     table1.DisableConstraints;
     table1.First;
     while not table1.eof do begin
      xm2:=table1.fieldbyname('name').asstring;
      nj2:=table1.fieldbyname('grade').asstring;
      bj2:=table1.fieldbyname('class').asstring;  if length(xm1)=0 then xmb:=true
       else if RadioGroup1.ItemIndex=0 then
        xmb:=comparetext(xm1,xm2)=0
         else xmb:=pos(xm1,xm2)>0;  if length(nj1)=0 then njb:=true
       else if RadioGroup1.ItemIndex=0 then
        njb:=comparetext(nj1,nj2)=0
         else njb:=pos(nj1,nj2)>0;  if length(bj1)=0 then bjb:=true
       else if RadioGroup1.ItemIndex=0 then
        bjb:=comparetext(bj1,bj2)=0
         else bjb:=pos(bj1,bj2)>0;  if xmb and bjb and njb then
        if RadioGroup1.ItemIndex=0 then break
        else
        begin
         rpt:=application.messagebox('是否这个人','请确认',mb_okcancel);
         if rpt=idok then break;
        end;
        table1.Next;
      end;  table1.EnableConstraints;
      if length(xm1+bj1+nj1)=0 then showmessage('查询条件为空')
       else if table1.eof then showmessage('没有找到')
        else showmessage('已经找到');
     end;xm,姓名
    bj,班级
    nj,年级