如何在sqlite中执行count查询并获取int作为行数

时间:2017-11-17 18:01:07

标签: android database sqlite

我想用where子句检索数据库中保存的已计数行数,在SQlite中,我是初学者并且很难执行此sql查询

Select Count(*) From " + Table_Seekers + " where " + Uid + " = " + Table_Seekers

我想获得数据库中计数的行数,其中传入的Uid在db中是相同的?所以请任何人帮忙。

public void getReqMade(String Uid) {
    SQLiteDatabase database = getReadableDatabase();
    database.execSQL("Select Count(*) From " + Table_Seekers + " where " + Uid + " = " + Table_Seekers);
}

1 个答案:

答案 0 :(得分:1)

如果Table_Seekers是表格的名称,而Uid就是您要搜索的内容,那么

Select Count(*) From Table_Seekers where Table_Seekers_field = Uid

此外,您应该以小写字母命名方法的参数。