adoquery查询成功后units字段有记录:'1011','1012','1021'等等设置
adoquery.filter := 'units like ''1___'';  //字符串是:  1 _ _ _
或者
adoquery.filter := 'units like ''1__1'';  //字符串是:  1 _ _ 1
adoquery.filtered := true;
后没有任何记录显示,实际上是有符合条件的记录的而设置
adoquery.filter := 'units like ''101_'';
或者
adoquery.filter := 'units like ''_01_'';后就可以有符合条件的记录显示,这是什么原因呢?

解决方案 »

  1.   

    adoquery.filter := 'units like ''1_'' and 'units like ''_1_''
      

  2.   

    sorry,不能误导同学!
    这是Delphi帮助给出的Filter字符表
    Operator Meaning
    < Less than
    > Greater than
    >= Greater than or equal to
    <= Less than or equal to
    = Equal to
    <> Not equal to
    AND Tests two statements are both True
    NOT Tests that the following statement is not True
    OR Tests that at least one of two statements is True
    + Adds numbers, concatenates strings, adds numbers to date/time values (only available for some drivers)
    - Subtracts numbers, subtracts dates, or subtracts a number from a date (only available for some drivers)
    * Multiplies two numbers (only available for some drivers)
    / Divides two numbers (only available for some drivers)
    * wildcard for partial comparisons (FilterOptions must include foPartialCompare)
      

  3.   

    下划线是支持的,但是我测试的结果是只能两侧或一侧的单个下划线,多了不行,中间也不行
    我试过在 FilterRecord 事件里进行过滤,结果是可以出来了,但是 recordcount 值永远不变,是未过滤时的值
      

  4.   

    filter 中好像也不能用 substring(unit,1,1) = '1' 这样的函数