Java check two tables within SQLite

1

I have a database that has two tables, being EstoqueDBQ and FilaDBQ , I need to create the following logic.

If the value exists in the FilaDBQ table and in stoqueDBQ , this value should be excluded from FilaDBQ, I thought I'd use the code below, but I'm having trouble adapting .

    String sql = "SELECT UM FROM FilaDBQ [.....]";
    Cursor data = database.rawQuery(sql, null);

    if (cursor.moveToFirst()) {
     Se é verdade, apagar o valor na tabela FilaDBQ
    } else {
   Se não, nada acontece.
    }
    
asked by anonymous 18.03.2016 / 13:16

1 answer

1

I have been able to solve this by doing the filter directly in the query, follow the query below.

SELECT UM FROM FILADBQ WHERE NOT IN (SELECT UM FROM ESTOQUEDBQ)

This condition only makes the filter or the data is not deleted from the database, but for my application this function is perfectly acceptable!

If someone needs to delete the record, just use the query below:

   DELETE FROM FILADBQ WHERE IN (SELECT UM FROM ESTOQUEDBQ)

Strong hug!

    
18.03.2016 / 15:35