Distinct rows from join
// FREEBIE
This commit is contained in:
parent
c342f0d7e4
commit
cb3f9a6805
2 changed files with 2 additions and 1 deletions
|
@ -309,7 +309,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||
|
||||
private Cursor rawQuery(@NonNull String where, @Nullable String[] arguments) {
|
||||
SQLiteDatabase database = databaseHelper.getReadableDatabase();
|
||||
return database.rawQuery("SELECT " + Util.join(MMS_PROJECTION, ",") +
|
||||
return database.rawQuery("SELECT DISTINCT " + Util.join(MMS_PROJECTION, ",") +
|
||||
" FROM " + MmsDatabase.TABLE_NAME + " LEFT OUTER JOIN " + AttachmentDatabase.TABLE_NAME +
|
||||
" ON (" + MmsDatabase.TABLE_NAME + "." + MmsDatabase.ID + " = " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.MMS_ID + ")" +
|
||||
" WHERE " + where, arguments);
|
||||
|
|
|
@ -222,6 +222,7 @@ public class MmsSmsDatabase extends Database {
|
|||
String unionQuery = unionQueryBuilder.buildUnionQuery(new String[] {smsSubQuery, mmsSubQuery}, order, limit);
|
||||
|
||||
SQLiteQueryBuilder outerQueryBuilder = new SQLiteQueryBuilder();
|
||||
outerQueryBuilder.setDistinct(true);
|
||||
outerQueryBuilder.setTables("(" + unionQuery + ")");
|
||||
|
||||
String query = outerQueryBuilder.buildQuery(projection, null, null, null, null, null, null);
|
||||
|
|
Loading…
Add table
Reference in a new issue