What is the best way to do SELECT
with INNER JOIN
and with various conditions using SQLite Android?
I thought I'd do it this way:
SQLiteQueryBuilder _QB = new SQLiteQueryBuilder();
_QB.setTables("TABELA_1 INNER JOIN TABELA_2
ON TABELA_1.ID =TABELA_2.TABELA_1_ID");
String[] columns = new String[]
{
" SUM (column1) as column1",
" SUM (column2) as column2"
};
String groupBy = "column1";
String selection = "column1=example1 AND column2=example2";
String orderBy = " column2 ASC ";
SQLiteDatabase db = beginTransactiongin();
Cursor cursor = _QB.query(SQLiteDatabase, columns, selection, null,groupBy, null,orderBy);