我在adotable的filter属性里想实现这样的语句:
adotable.filter:='x='''+value1+''' and (y='''+value2+''' or z='''+value3+''')';
在执行adotable.filtered:=ture;时报错 说什么:不在匹配范围之内....或与其他参数冲突...
但我将该语句写成 
adotable.filter:='x='''+value1+''' and y='''+value2+''' or z='''+value3+'''';
则可以顺利通过,但这又不是我想要的效果,请问如何写才能实现第一种情况?(我只想用adotable的
filter属性或onfilterrecoed事件)谢谢

解决方案 »

  1.   

    There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this: 
    =================================================================
    (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
    =================================================================
    Instead, you would construct this filter as 
    =================================================================
    (LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
    =================================================================这是MSDN上面的原话。
      

  2.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdprofilter.asp(E文,MSDN)AND 和 OR 在级别上没有先后之分。可使用括号将子句分组。但不能象以下示例那样先将由 OR 联接的子句分组,然后将该组用 and 联接到其他子句。
    (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'与之相反,可以构造如下形式的筛选:
    (LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
    http://www.51windows.net/pages/ado/?url=/pages/ado/mdprofilter.htm(中文,ADO程序员参考)