Android SQLite Delete row issue

2019-04-05 08:55发布

I am trying to delete a row from a table but i have three WHERE clauses and i am not sure if i am using the correct statement.

    db.delete(DBAdapter.TableName, "Id="+ Id
          +" AND WHERE QstnrId = "+Integer.parseInt(QuestionnaireId)
          +" AND WHERE QstnId = "+Integer.parseInt(QuestionId), null);

I am almost certain i am not using the statement correctly. Please assist?

1条回答
forever°为你锁心
2楼-- · 2019-04-05 09:13

You don't need to use the WHERE keyword. Also you could try using the third parameter to delete():

db.delete(DBAdapter.TableName, "Id=? AND QstnrId=? AND QstnId=?",
          new String[] { Id.toString(), QuestionnaireId, QuestionId });
查看更多
登录 后发表回答