0
Cursor cursor = db.rawQuery("SELECT id,name FROM  people WHERE id="+ id + " AND name IS NULL",null); 

我不想只将一个 id 的记录加载到我的游标中,而是想加载一系列 id,例如从 id=100 到 id=150 到游标。我怎样才能做到这一点 ?

4

4 回答 4

2

您可以通过更改WHERE子句中使用的运算符来做到这一点。

SELECT id, name FROM  people WHERE id>100 AND id<150 AND name IS NULL
于 2012-06-04T00:43:00.977 回答
2

试试这些查询

SELECT id, name FROM  people WHERE id >= 100 AND id <= 150 AND name IS NULL
SELECT id, name FROM  people WHERE id BETWEEN 100 AND 150 AND name IS NULL
于 2012-06-04T00:51:44.937 回答
1
Cursor cursor = db.rawQuery("SELECT id,name FROM  people WHERE id <"+ upperBoundId + " AND id > " + lowerBoundId" + AND name IS NULL",null);
于 2012-06-04T00:42:31.330 回答
0

试试这个:

Cursor c = db.rawQuery("select id,name from people where id>100 and id<150 and name is null",null);
int Column1 = c.getColumnIndex("id");
int Column2 = c.getColumnIndex("name");
c.moveToFirst();
   if (c != null) {
    // Loop through all Results
    do {
         int id = c.getInt(Column1);
     String name = c.getString(Column2);

    }while(c.moveToNext());
于 2012-06-04T00:47:14.703 回答