Query is repeating results - SQLite

0

I am doing a query in my SQLite bd, but it is returning me some repeated results I can not find the error.

 cursor = db.Select(DataBaseHandler.TABLE_OS + " LEFT JOIN " + DataBaseHandler.TABLE_SITUACAO + " ON " + DataBaseHandler.TABLE_SITUACAO + "." + DataBaseHandler.KEY_SITUACAO_ID + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_SITUACAO +
                            " LEFT JOIN " + DataBaseHandler.TABLE_CLIENTES + " ON " + DataBaseHandler.TABLE_CLIENTES + "." + DataBaseHandler.KEY_CLIENTES_ID + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_CLIENTE +
                            " LEFT JOIN " + DataBaseHandler.TABLE_FINANCEIRO + " ON " + DataBaseHandler.TABLE_FINANCEIRO + "." + DataBaseHandler.KEY_FINANCEIRO_ID_OS + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_ID_SEQUENCIA +
                            " LEFT JOIN " + DataBaseHandler.TABLE_SERVICOS + " ON " + DataBaseHandler.TABLE_SERVICOS + "." + DataBaseHandler.KEY_SERVICO_ID_OS + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_ID_SEQUENCIA +
                            " LEFT JOIN " + DataBaseHandler.TABLE_PECAS_OS + " ON " + DataBaseHandler.TABLE_PECAS_OS + "." + DataBaseHandler.KEY_PECAS_OS_ID_OS + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_ID_SEQUENCIA,

                    null, null, null, null, null, DataBaseHandler.KEY_OS_ID_SEQUENCIA + " DESC", null);
    
asked by anonymous 14.04.2017 / 18:47

1 answer

0

I solved the problem using the INSTINCT clause

 cursor = db.Select(DataBaseHandler.TABLE_OS + " LEFT JOIN " + DataBaseHandler.TABLE_SITUACAO + " ON " + DataBaseHandler.TABLE_SITUACAO + "." + DataBaseHandler.KEY_SITUACAO_ID + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_SITUACAO +
                        " LEFT JOIN " + DataBaseHandler.TABLE_CLIENTES + " ON " + DataBaseHandler.TABLE_CLIENTES + "." + DataBaseHandler.KEY_CLIENTES_ID + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_CLIENTE +
                        " LEFT JOIN " + DataBaseHandler.TABLE_FINANCEIRO + " ON " + DataBaseHandler.TABLE_FINANCEIRO + "." + DataBaseHandler.KEY_FINANCEIRO_ID_OS + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_ID_SEQUENCIA +
                        " LEFT JOIN " + DataBaseHandler.TABLE_SERVICOS + " ON " + DataBaseHandler.TABLE_SERVICOS + "." + DataBaseHandler.KEY_SERVICO_ID_OS + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_ID_SEQUENCIA +
                        " LEFT JOIN " + DataBaseHandler.TABLE_PECAS_OS + " ON " + DataBaseHandler.TABLE_PECAS_OS + "." + DataBaseHandler.KEY_PECAS_OS_ID_OS + "=" + DataBaseHandler.TABLE_OS + "." + DataBaseHandler.KEY_OS_ID_SEQUENCIA,

                new String[]{"INSTINCT "+DataBaseHandler.KEY_OS_ID_SEQUENCIA}, null, null, null, null, DataBaseHandler.KEY_OS_ID_SEQUENCIA + " DESC", null);
    
06.05.2017 / 02:41