Java check two tables inside Sqlite

Asked

Viewed 225 times

1

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

If the value exists in the table Filadbq and in the EstoqueDBQ, this value should be deleted from Filadbq, thought to 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.
    }

1 answer

1


Dear I managed to solve by performing the filter directly in the query, follows 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 erased 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)

Hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.