如何在 react-native-sqlite-storage 的查询中使用 LIKE
how to use LIKE in query of react-native-sqlite-storage
我想获取名称包含 "Angel" 的每个用户。这是我的代码
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}%`]
我想获取名称包含 "Angel" 的每个用户。这是我的代码
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}%`]