Search code examples
sqlfilteradvantage-database-serverwhere-in

Can I use an "IN" filter on an Advantage Database Table (TAdsTable)?


I want to apply a filter to an advantage table using multiple values for an Integer field.

The equivalent SQL would be:

SELECT * FROM TableName WHERE FieldName IN (1, 2, 3)

Is it possible to do the same on an AdsTable within having to repeat the field using an "OR"?

I want to something like:

Filter := 'FieldName IN (1, 2, 3)'

Instead of:

Filter := 'FieldName = 1 OR FieldName = 2 OR FieldName = 3'

Solution

  • It is possible to use the INLIST function for this. That function exists for Visual FoxPro compatibility. It would look like:

    Filter := 'InList(FieldName, 1, 2, 3)';
    

    However, I do not believe that it is currently optimized to use an index. So if the table is very large, it will be much more efficient to use the FieldName = 1 OR FieldName = 2 ... version of the filter.