Answer the question
In order to leave comments, you need to log in
Switching to Realm, how to execute such a request?
I'm moving the project to realm, how can I query multiple tables in it?
There was a request like this:
public Integer getPrescriptionsCount(Date from, Date to) {
List<PrescriptionItem> items = new ArrayList<>();
SQLiteDatabase db = this.getWritableDatabase();
try {
String selectQuery = "SELECT * FROM " + TABLE_PRESCRIPTIONS + "," + TABLE_EXEC_TEMPLATE
+ " WHERE " + TABLE_PRESCRIPTIONS + "." + KEY_PRESCRIPTIONS_START_DATE + " <= '" + dateFormatWOutTime.format(from) + " 00:00:00' AND ("
+ TABLE_PRESCRIPTIONS + "." + KEY_PRESCRIPTIONS_END_DATE + " >= '" + dateFormatWOutTime.format(to) + " 99:99:99'"
+ " OR " + TABLE_PRESCRIPTIONS + "." + KEY_PRESCRIPTIONS_END_DATE + " IS NULL)"
+ " AND " + TABLE_EXEC_TEMPLATE + "." + KEY_EXEC_TEMPLATE_PRESCRIPTION_ID + " = " + TABLE_PRESCRIPTIONS + "." + KEY_ID
+ " ORDER BY " + TABLE_EXEC_TEMPLATE + "." + KEY_EXEC_TEMPLATE_DISPLAY_ORDER;
Log.e(LOG, selectQuery);
Cursor c = db.rawQuery(selectQuery, null);
return c.getCount();
} finally {
db.close();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question