2

I would like to delete a record in the database with multiple WHERE arguments.

My database helper class has this method:

    public void deleteManualRow(String where){
    try {db.delete(TABLE_NAME_MANUAL, where, null);}
    catch (Exception e)
    {
        Log.e("DB ERROR", e.toString());
        e.printStackTrace();
    }
}

The "where" string which is passed to this method is seen as this through the debugger:

eventName='Manual Event 6' AND eventStartTime='2011-07-18T05:40:00.000-0400' AND eventEndTime='2011-07-18T06:40:00.000-0400'

How am I supposed to structure this WHERE clause if I want to delete a record with multiple arguments for WHERE? All of the datatypes are strings.

2 Answers 2

4

like this db.delete(TABLE_NAME_MANUAL,"Column1='5' and column2 like '3'", null);

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your response, but the error in my code wasn't because of my SQL syntax. I was trying to delete a record that actually didn't even exist, hence no result...very dumb mistake on my part. For discussions sake, I see that in your response you use 'like' instead of '=' for column2. Why use 'like' instead of '='? Are '=' and 'like' interchangeable because my code is working when using '=' for column2.
still two is different you know
1

You have to learn your sqlite api, next I show from Android flutter example.

From sqlite_api.dart:

Future<int> delete(String table, {String where, List<dynamic> whereArgs});

So your result code will be:

await db.delete(tableName, where: 'place_id = ? and country_id = ?', whereArgs: [place_id, country_id]);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.