how to add WHERE clause to Query on android

后端 未结 3 1042
清酒与你
清酒与你 2021-02-19 19:13

I would like to limit the results to those whose KEY_HOMEID is equal to journalId. I\'ve been on this for a couple days any help would be appreciated.

public Curso

3条回答
  •  借酒劲吻你
    2021-02-19 19:45

    Have a look at http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#query

    Your query should look a little like this:

    mDb.query(DATABASE_TABLE, // Table name
              columnNames, // String[] containing your column names
              KEY_HOMEID+" = "+jounalId, // your where statement, you do not include the WHERE or the FROM DATABASE_TABLE parts of the query,
              null,
              null,
              null,
              null
             );
    

    If you feel more comfortable writing sql queries you can also use:

    mDb.rawQuery("SQL STATEMENT", null);
    

提交回复
热议问题