私は1つのテーブルヒストリーを持っています。SQLite android count by名前
履歴テーブルには、私はこのような結果必要前方に私のアプリから私
例
1 | 12.12.2019 | 88801
2 | 11.11.2019 | 88802
3 | 13.1.2019 | 88802
4 | 1.2.2015 | 88801
5 | 7.8.2019 | 88801
名は名前のようであるすべての画像をカウントする必要が3列
ID | timestamp | imagename
を持っています
Image name| number of images
8801 | 3
8802 | 2
...
転送された変数imageNameでカウントする必要があります。
これは私が
public List<HistoryLog> getAllHistoryLogsForListView(String imageName) {
List<HistoryLog> historyLogList = new ArrayList<>();
// Select All Query ORDER BY Timestamp | SORT ASC | LIMIT 150 rows
String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " ORDER BY " + KEY_TIMESTAMP + " ASC " + " LIMIT 150";
SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
HistoryLog historyLog = new HistoryLog();
historyLog.setId(Integer.parseInt(cursor.getString(0)));
historyLog.setTimeStamp(cursor.getString(1));
historyLog.setImageName(cursor.getString(2));
// Adding history logs to list
historyLogList.add(historyLog);
} while (cursor.moveToNext());
}
db.endTransaction();
// return history logs list
return historyLogList;
}
あなたが実際に望むものは明確ではありませんか? –
私は何枚の画像が同じ名前を持っているか知りたい – Adnan