Home > Software engineering >  Flutter SQFLITE how to remove an entry matching TWO fields
Flutter SQFLITE how to remove an entry matching TWO fields

Time:07-21

   await _database!.delete(
    "row",
    where: "id = ?",
    whereArgs: [id],
  );

I want to remove an entry based on both ID and DATETIME,

something like this;

      await _database!.delete(
    "row",
    where: "id = ?" && "DateTime = ?", <----- Doesn't actually work
    whereArgs: [id, day],
  );

How do I go about doing this? .delete only accepts a single string.

CodePudding user response:

It seems you just pass the SQL WHERE part of the command there as a single string:

where: "id = ? AND DateTime = ?"

CodePudding user response:

Try using and


await _database!.delete(
    "habits",
    where: "id = ?" and "DateTime = ?", 
    whereArgs: [id, day],
  );

CodePudding user response:

Try this one:

await _database!.delete(
    "row",
    where: "id = ? AND DateTime = ?",
    whereArgs: [id, day],
  );
  • Related