Ask for insertion or update query in SQLite Android

0

In my application I have defined a database in which I will store numbers from 1 to 99 as they go out, if they leave more than once it will be stored how many times each one has left. The problem comes to me when formulating the query, I need that well, if the number does not exist this is added to the database and that if it exists, the number of times that it has left is updated. I tried to do it with this query but I do not get anything.

Where -n- is the number in question that I need to check. tableBingo is the BD and times Out is the number of times a number has come out. It must be said that the numbers will be added one by one always in the event that they are repeated.

db.execSQL("IF EXISTS (SELECT " + n + " FROM tablaBingo) INSERT INTO  tablaBingo (numero,vecesSalido) VALUES (" + n + ", "+0+") ELSE UPDATE tablaBingo SET vecesSalido = vecesSalido+1 WHERE numero = " + n + "");
    
asked by David Sanchez Calvo 29.12.2018 в 19:38
source

0 answers