【问题标题】:Flutter SQFLITE how to remove an entry matching TWO fieldsFlutter SQFLITE如何删除匹配两个字段的条目
【发布时间】:2022-07-21 22:12:56
【问题描述】:
   await _database!.delete(
    "row",
    where: "id = ?",
    whereArgs: [id],
  );

我想删除一个基于 ID 和 DATETIME 的条目,

类似的东西;

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

我该怎么做呢? .delete 只接受一个字符串。

【问题讨论】:

    标签: flutter dart sqflite


    【解决方案1】:

    看来您只是将命令的 SQL WHERE 部分作为单个字符串传递:

    where: "id = ? AND DateTime = ?"
    

    【讨论】:

      【解决方案2】:

      尝试使用和

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

      【讨论】:

        【解决方案3】:

        试试这个:

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

        【讨论】:

          猜你喜欢
          • 2010-10-14
          • 1970-01-01
          • 1970-01-01
          • 2017-07-06
          • 2021-12-26
          • 1970-01-01
          • 2018-04-28
          • 2019-09-22
          • 1970-01-01
          相关资源
          最近更新 更多