Amit Kumar Kannaujiya
Amit Kumar Kannaujiya

Reputation: 35

Passing parameter in Sql IN statement

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 ?

Upvotes: 1

Views: 80

Answers (1)

laalto
laalto

Reputation: 152817

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" });

Upvotes: 1

Related Questions