Search code examples
sqlgoogle-fusion-tablesapp-inventor

GetRowsWithConditions in the condition I can use AND but not OR


I'm trying to get some rows from a table using the GetRowsWithConditions method in App Inventor 2. I've used AND and it works correctly but when I use OR I get
400 Bad Request Invalid query: Parse error near 'OR'.

The condition is

WHERE ROWID=1 OR ROWID=1001 OR ROWID=2001

Solution

  • As Taifun mentioned, "OR" is not supported in Fusion Tables, but an alternative suggested by Google is to use "IN".

    Wikipedia Entry:

    IN will find any values existing in a set of candidates.

    SELECT ename WHERE ename IN ('value1', 'value2', ...)
    

    All rows match the predicate if their value is one of the candidate set of values. This is the same behavior as

    SELECT ename WHERE ename='value1' OR ename='value2'
    

    except that the latter could allow comparison of several columns, which each IN clause does not. For a larger number of candidates, IN is less verbose.


    So in theory*, your query would be reformatted to:

    ... WHERE ROWID IN ('1','1001','2001')
    

    Hope that helps!

    *I say in theory, because I've never used ROWID as the filter as I've always created a custom ID column.