部门 (取值于 combobox1) 关系 =EdtDept.text
联接关系(取值于 combobox3)关系 and
地区 (取值于 combobox2) 关系 =EdtReg.Text 
语句是这样写的,
但是在部门和地区间加个and或or那语句该怎么写呀!
请指点!
有例子最好。

解决方案 »

  1.   

    if (部门) AND (地区) THEN
      

  2.   

    to:cg1120(代码最优化-§新年祝福你,好运伴着你§)
    你的语句好象是表静态的,动态的怎么写呀
    if (部门) AND (地区) THEN
    是这样呀!
    但是我是用combobox3来赋值的应怎么写呀
    联接关系(取值于 combobox3)关系 and
      

  3.   

    部门 (取值于 combobox1) 关系 =EdtDept.text
    联接关系(取值于 combobox3)关系 and或or
    地区 (取值于 combobox2) 关系 =EdtReg.Text 
    联接关系(取值于 combobox4)关系 and或or
    金额 (取值于 edit1)     关系 >、<、=、>=、<= (取值于 combobox5)
    这样的又该怎么写呀!我主要是中间那个联接关系不太懂,请指点!
      

  4.   

    是不是这种:
    if (combobox1.text=edtdept.text) and (commbobox2=edtreg.txt).....then
      

  5.   

    to:cg1120(代码最优化-§新年祝福你,好运伴着你§)
    if (combobox1.text=edtdept.text) and ommbobox2=edtreg.txt).....then
    这个有点接近了,那你是怎么处理联接关系的
    部门 (取值于 combobox1) 关系 =EdtDept.text
    联接关系(取值于 combobox3)关系 and或or
    地区 (取值于 combobox2) 关系 =EdtReg.Text 
    联接关系(取值于 combobox4)关系 and或or
    金额 (取值于 edit1)     关系 >、<、=、>=、<= (取值于 combobox5)
      

  6.   

    sqlstr := 'select * from table1 where (fdate = ''2002-1-1'') ';
    if length(combobox1.text) > 0 then
      sqlstr := sqlstr + ' and (fdepart = ''' + combobox1.text + ''')';
    if length(combobox2.text) > 0 then
      sqlstr := sqlstr + ' and (fempno = ''' + combobox2.text + ''')';...执行sqlstr语句在最前面,需要有一个条件,就是必须的,要不然,where后面直接接and就出错了嘛。你不至于搜索整张表吧,一定不要条件话,就放个屁在上面也行,就像where (1 = 1)呵呵,士是士了点,但有效,把所有的可选项都列到这个sql语句里面去就行了
      

  7.   

    to:blueshrimp(天空还下着沙)
    我主要是不明白这种联接关系怎么处理
    部门 (取值于 combobox1) 关系 =EdtDept.text
    联接关系(取值于 combobox3)关系 and或or
    地区 (取值于 combobox2) 关系 =EdtReg.Text 
    联接关系(取值于 combobox4)关系 and或or
    金额 (取值于 edit1)     关系 >、<、=、>=、<= (取值于 combobox5)
      

  8.   

    这样呢
    if (combox1.text=edtdept.text) and 
    ((combobox2.text=edtreg.text) and/or (comobox3.text=edtreg.text))
    and ((combobox4 关系 combox5.text) and/or (edit1.text 关系 combox5.text)) then
      

  9.   

    我要实现多条件查询具体是这样的:
    查询字段(取值于combobox1) 匹配条件(取值于 combobox2)值为= < > <> 
    查询值 (取值于 EDIT1.text)
    联接关系(取值于combobox3)关系 and或or
    查询字段(取值于combobox4) 匹配条件(取值于 combobox5)值为= < > <>
    查询值 (取值于 EDIT2.text)
    联接关系(取值于combobox6)关系 and或or
    查询字段 (取值于combobox7)匹配条件(取值于 combobox8)值为= < > <> 
    查询值 (取值于 EDIT3.text)
      

  10.   

    var SQLstr:string;
    begin
      SQLstr:=combobox1.text+' '+combobox2.text+' '+edit1.text;
      if combobox3.text<>'' then
        begin
           SQLstr:=SQLstr+' '+combobox3.text+' '+combobox4.text+' '+combobox5.text+''+edit2.text;
        end;
      if combobox6.text<>'' then
        begin
          SQLstr:=SQLstr+' '+combobox6.text+' '+combobox7.text+' '+combobox8.text+' '+edit2.text;
        end;
      query1.close;
      query1.sql.clear;
      query1.sql.add(SQLstr);
      query1.open;
    end;
      

  11.   

    SQLstr:=SQLstr+' '+combobox6.text+' '+combobox7.text+' '+combobox8.text+' '+edit2.text;应该为edit3.text吧
    能说下这句的意思吗?
    SQLstr:=SQLstr+' '+combobox3.text+' '+combobox4.text+' '+combobox5.text+''+edit2.text;
      

  12.   

    是的!我写错了!SQLstr:=SQLstr+' '+combobox3.text+' '+combobox4.text+' '+combobox5.text+''+edit2.text;
    //局部变量sqlstr等于 自己 加上 空格 加上 逻辑 加上 空格 加上 字段名 加上 空格 加上 表达式 加上 空格 加上 值
      

  13.   

    另:你注意SQLstr:=SQLstr+' '+combobox3.text+' '+combobox4.text+' '+combobox5.text+' "'+edit3.text+'"';
    如果是字符型非数值型的字段值要加"号!
      

  14.   

    谢谢,如果你愿意的话可以把我加到QQ里我的QQ号为:2768926结帖了。