我有一个不返回任何值的 sql 查询,但它有要返回的数据。以下查询代码
Cursor cursor = db.query(CrimeDB.NOME_TABELA, CrimeDB.COLUNAS,
CrimeDB.ID_CIDADE + "=" + idCidade + "" + " AND "
+ CrimeDB.TIME + " >= datetime('" + dataInicioFormatada
+ "') AND " + CrimeDB.TIME + " <= datetime('"
+ dataFimFormatada + "')" + " AND "
+ CrimeDB.GRUPO_CRIME + "=" + idCategoria + "", null,
null, null, null);
读取光标
if (cursor.moveToFirst()) {
do {
crime = new Crime();
crime.setLastUpadateToken(ultimoTokenValido
.getUltimoTokenAtualizado());
listCrime.add(itemCrime);
} while (cursor.moveToNext());
}
查询结果为:
SELECT
grupo_crime_id_grupo_crime,
id_crime,
cities_id_cities,
time
FROM
crime
WHERE
cities_id_cities=1650 AND
time >= datetime('20-10-2012') AND
time <= datetime('22-05-2014') AND
grupo_crime_id_grupo_crime=1
因为数据库中存在价值,所以返回以实现任何价值。使用 SQLite 编辑器,我看到表犯罪记录。
id_crime | cities_id_cities | grupo_crime_id_grupo_crime | time
1 1650 1 28-03-2013
2 1650 1 06-04-2013