我通过另一个类中的putExtra和getStringExtra方法检索了2个值。 BOth这些值是正确的。我需要在我的SQL查询中使用这两个值:
final Cursor cursor = sdb.rawQuery("SELECT match_player_name FROM match_response WHERE match_date=? AND " +
"match_response =?"+new String [] {String.valueOf(date),String.valueOf(response)}, null);
我不熟悉使用带有多个条件的rawQuery。我有正确的语法吗?我的SQLite
数据库中有一条满足此条件的记录。
答案 0 :(得分:2)
这是一个例子:
Cursor cur = database.rawQuery("select name from Table where ID=? and SubCategoryID=?",
new String [] {String1,String2});
答案 1 :(得分:0)
public Cursor getMachineServices(){
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery("select row1, from maquina where something = x AND somethingelse = y", new String[]{});
return c;
}
然后,在您要显示它的活动中,您必须执行以下操作:
Database db;
db = new Database(yourActivity);
Cursor c = db.getMachineServices);
if (c.moveToFirst()) {
do {
String machines
c.getString(c.getColumnIndex("row1"));
//you can use the variable machines where you want
} while (c.moveToNext());
}