无法使用rawQuery正确执行删除查询

Sha*_*adi 5 sqlite android android-sqlite

我想删除一些表info比较另一个表type,我的代码如下所示.我没有收到任何错误或异常仍然无法删除数据.请建议我

 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();
}
Run Code Online (Sandbox Code Playgroud)

nic*_*ico 11

该方法SQLiteDatabase.rawQuery()用于查询 - > SELECT语句.

要使用原始SQL 修改数据,您需要使用SQLiteDatabase.execSQL().