sql - 如何在flutter上查询sqflite多个whereArgs?
问题描述
如何查询多个 whereArgs?我总是返回 1 行。它应该返回 3 行。
final res = await db.query(
Constants.dbTable,
where: "name = ?",
whereArgs: ['read', "uio", 'go'],
);
解决方案
尝试使用 IN 子句:
final res = await db.query(
Constants.dbTable,
where: "name IN (?, ?, ?)",
whereArgs: ['read', 'uio', 'go'],
);
更新!
对于动态List<String> names
,您可以尝试使用这种方法:
final res = await db.query(
Constants.dbTable,
where: "name IN (${('?' * (names.length)).split('').join(', ')})",
whereArgs: names,
);
推荐阅读
- r - 删除日期以特定 ID 为条件的行
- javascript - 阴影隐藏在元素svg之外
- cocoa - 什么情况下 NSWindowController 的文档可以改变?
- elasticsearch - 没有聚合的唯一值查询
- java - GridCoverage2D 上的 Geotools ViewType
- c++ - 您能否通过 unique_ptr 返回派生类的实例,而该静态成员函数是在其基类中定义的?
- c++ - 为什么相同的代码在不同的机器上产生两个不同的 fp 结果?
- jenkins - 在jenkins groovy中执行'curl'时出错
- spring - Spring 集成 JpaExecutor
- debugging - 安装 Office 365 后,Visual Studio 6 调试器返回异常代码:c0000005