Android:select语句where子句的两个条件?

时间:2014-09-21 13:23:18

标签: android database sqlite

在赋值语句中whereClString是否为真? 我需要的是从table中选择all =" tweetType"和Id =" userId"

    String whereClString = LikeDatabaseHelper.TWEETS_TYPE + "=? AND " + LikeDatabaseHelper.USER_ID + "=?";
    String[] args = new String[] { tweetType, String.valueOf(userId) };
    try {

        cursor = timelineDB.query(table, null, whereClString, args, null, null, LikeDatabaseHelper.TIME_COL
                + " DESC");

    } catch (Exception e) {
        e.printStackTrace();

    }

    return cursor;

1 个答案:

答案 0 :(得分:0)

使用:

String whereClString = LikeDatabaseHelper.TWEETS_TYPE + "='" + tweetType.toString() + "' AND " + LikeDatabaseHelper.USER_ID + "='" + userId.toString() + "'" ;