Android rawQuery有两个条件

时间:2012-12-01 10:12:58

标签: android sqlite count

我遇到了如何在rawQuery中放置AND条件的问题。我想getCount WHERE SQLiteHelper.product_FId =listId AND SQLiteHelper.product_Status==1 ...我应该在哪里添加其他条件WHERE SQLiteHelper.product_Status==1

public int getCountComplePro(String listId) {
        // TODO Auto-generated method stub
        String[] args = { listId };
        int x = 0;
        Cursor cur=database.rawQuery("SELECT * FROM "
                + SQLiteHelper.productTable + " WHERE "
                + SQLiteHelper.product_FId +"=?" ,args);

       x=cur.getCount();

}

        cur.close();
        return x;

希望有人能指导我解决这个问题...

1 个答案:

答案 0 :(得分:1)

String[] args = { listId };
Cursor cur=database.rawQuery("SELECT * FROM "
                + SQLiteHelper.productTable + " WHERE "
                + SQLiteHelper.product_FId +"=?"
                + "AND "+SQLiteHelper.product_Status+ "=1",args);

不应该这样做吗?