Passing parameter in Sql IN statement

99 views Asked by At

How can I pass a parameter in the IN SQL statement ?

cursor = readableDb.rawQuery("SELECT * FROM User where User.objectId NOT IN (@Par)", new String{"ID"} );

Is it the correct way to do it ?

1

There are 1 answers

3
laalto On BEST ANSWER

Variables get bound with a single literal value. If you have many values, you need a separate ? placeholder for each.

Example:

cursor = readableDb.rawQuery("SELECT * FROM User where objectId NOT IN (?,?,?)",
    new String[] { "1", "2", "3" });