WHERE IN clause in Android sqlite?

前端 未结 7 1676
無奈伤痛
無奈伤痛 2020-12-31 09:18

I can\'t get WHERE IN clause to work on android SQLite database.

Is there any way to execute a statement like this in android? :

SELECT body FROM ta         


        
相关标签:
7条回答
  • 2020-12-31 09:43

    Adding to Cristian answer: While his answer will work, you should try to use the correct way of querying:

    db.rawQuery("Select * from table1 where title = ?", new String[]{param1});

    This approach can also be used with WHERE IN clause, but the passed string has to be in format of 'asd','zxc','qwe'

    Like this:

    String param1 = "\'asd\',\'zxc\',\'qwe\'";
    db.rawQuery("Select * from table1 where title in (?)", new String[]{param1});
    
    0 讨论(0)
提交回复
热议问题