How to pass two or more selection argument in “query” method

后端 未结 4 2013
温柔的废话
温柔的废话 2020-12-11 04:00

I am using query method, but I don\'t no how to pass more than one selection argument in query method.

My query method should return result as same as this sql stat

4条回答
  •  情书的邮戳
    2020-12-11 04:09

    Try something like that..

    SQLiteDatabase db = YourDatabaseHelper.getReadableDatabase();
    String TABLE = "CONTACT_TAGS";
    String[] FIELDS = { "_id" };
    String WHERE =  "TAG1='tagname' OR TAG2='tagname' OR TAG3='tagname' OR TAG4='tagname' OR TAG5='tagname' ";
    // Execute
    cursor = db.query(TABLE, FIELDS, WHERE, null, null, null, null);
    

    If you read the documentation of the Cursor.query() method you find the definition for selection as follows:

    selection: A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given table.

提交回复
热议问题