react-native-sqlite-storage - 如何在 react-native-sqlite-storage 查询中使用 LIKE
问题描述
我想让每个名字都包含“天使”的用户。这是我的代码
this.DATABASE.transaction(tx => {
tx.executeSql(
"SELECT * FROM tblUser WHERE Name LIKE '%?%'",["Angel"],
(tx, data) => {
var result = [];
for (let i = 0; i < data.rows.length; i++) {
result.push(data.rows.item(i));
}
},
})
但我得到了错误"Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters."
它只知道它什么?
时候独立,不像我的查询那样理解。这个问题有什么解决办法吗?
解决方案
采用
"SELECT * FROM tblUser WHERE Name LIKE ?",[`%${Angel}%`]
推荐阅读
- java - Java groovy 流比较两个列表并返回单个布尔变量
- unity3d - 获取对序列化列表的引用
在统一 - c# - 在 C# Mono 中使用 Xlib 设置“前景”窗口
- opencv4 - opencv+SaperaLT++ 带有垃圾名称的多个不需要的窗口
- python - 使用棉花糖验证架构时出现 AttributeError
- java - 如何在 Java 数组中建模相互依赖的工作表?
- r - 如何在用户定义函数的 write.csv 参数中放置字符串
- java - Flink 将所有流元素保存在 HashMap 中
- xamarin.forms - MvvmCross.Forms - 自定义 NavigationBar(其中包含 SearchBar)
- c++ - Qtopengl,为什么不能使用不同的vbo绘制两个立方体