我有一个名为CAL的数据库。它有两个列,MONTH和DAY。让我们说我在那里有一个名为5月8日的日期。可以进入MONTH栏,8进入DAY栏。我知道如何搜索单个列,例如,在MONTH列中找到具有May的行:
SQLiteDatabase db = sqLiteOpenHelper.getReadableDatabase();
Cursor cursor = db.query("CAL",
new String[]{"MONTH","DAY"},
"MONTH = ?",
new String[]{"May"},
null,null,null);
if (cursor.moveToFirst()){
String monthFromCursor = cursor.getString(0);
monthOutput.setText(monthFromCursor);
}
我想知道是否有办法同时搜索多列中的数据?例如,使用光标找到MONTH为May且DAY为8的行。这可能吗?
SQLiteDatabase db = sqLiteOpenHelper.getReadableDatabase();
Cursor cursor = db.query("CAL",
new String[]{"MONTH","DAY"},
"MONTH = ?",//Can I place something here???
new String[]{"May", Integer.toString(8)},
null,null,null);
if (cursor.moveToFirst()){
String monthFromCursor = cursor.getString(0);
monthOutput.setText(monthFromCursor);
}