I want to deleting some rows of table info
comparing another table type
,
my code goes as below. I am not getting any error or exception still I am unable to delete the data. Please suggest me
String query = "delete from info where _id in " +
"( select a._id " +
" from info a, type b," +
" where a.t_id = b._id and b.type_name = 'Petrol' )";
try{
database.rawQuery(query,null);
}catch (Exception e){
e.printStackTrace();
}
The method SQLiteDatabase.rawQuery()
is meant for querying --> SELECT statement.
To modify your data with raw SQL, you need to use SQLiteDatabase.execSQL()
.
database.rawQuery(query,null).moveToFirst();
instead of
database.rawQuery(query,null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With